forked from firebase/geofire-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
123 lines (104 loc) · 2.91 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**************/
/* REQUIRES */
/**************/
var gulp = require("gulp");
// File IO
var streamqueue = require("streamqueue");
var concat = require("gulp-concat");
var jshint = require("gulp-jshint");
var uglify = require("gulp-uglify");
var runSequence = require('run-sequence');
// Testing
var karma = require("gulp-karma");
/****************/
/* FILE PATHS */
/****************/
var paths = {
destDir: "dist",
scripts: {
src: {
dir: "src",
files: [
"src/*.js"
]
},
dest: {
dir: "dist",
files: {
unminified: "geofire.js",
minified: "geofire.min.js"
}
}
},
tests: {
config: "tests/karma.conf.js",
files: [
"bower_components/firebase/firebase.js",
"bower_components/rsvp/rsvp.min.js",
"src/*.js",
"tests/specs/*.spec.js"
]
}
};
/***********/
/* TASKS */
/***********/
/* Lints, minifies, and concatenates the script files */
gulp.task("scripts", function() {
// Concatenate all src files together
var stream = streamqueue({ objectMode: true });
stream.queue(gulp.src("build/header"));
stream.queue(gulp.src(paths.scripts.src.files));
stream.queue(gulp.src("build/footer"));
// Output the final concatenated script file
return stream.done()
// Rename file
.pipe(concat(paths.scripts.dest.files.unminified))
// Lint
// .pipe(jshint())
// .pipe(jshint.reporter("jshint-stylish"))
// .pipe(jshint.reporter("fail"))
// .on("error", function(error) {
// throw error;
// })
// Write un-minified version
.pipe(gulp.dest(paths.scripts.dest.dir))
// Minify
.pipe(uglify({
preserveComments: "some"
}))
// Rename file
.pipe(concat(paths.scripts.dest.files.minified))
// Write minified version to the distribution directory
.pipe(gulp.dest(paths.scripts.dest.dir))
// Write minified version to the examples directories
.pipe(gulp.dest("examples/fish1/js/vendor/"))
.pipe(gulp.dest("examples/fish2/js/vendor/"))
.pipe(gulp.dest("examples/fish3/js/vendor/"))
.pipe(gulp.dest("examples/sfVehicles/js/vendor/"))
.pipe(gulp.dest("examples/queryBuilder/js/vendor/"))
.pipe(gulp.dest("examples/html5Geolocation/js/vendor/"));
});
/* Uses the Karma test runner to run the Jasmine tests */
gulp.task("test", function() {
return gulp.src(paths.tests.files)
.pipe(karma({
configFile: paths.tests.config,
action: "run"
}))
.on("error", function(error) {
throw error;
});
});
/* Re-runs the "scripts" task every time a script file changes */
gulp.task("watch", function() {
gulp.watch(["build/*", paths.scripts.src.dir + "/**/*"], ["scripts"]);
});
/* Builds the distribution files */
gulp.task("build", ["scripts"]);
/* Runs the "test" and "scripts" tasks by default */
gulp.task("default", function(done) {
runSequence("scripts", "test", function(error) {
done(error && error.err);
});
});