-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
44 lines (39 loc) · 1.28 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
var gulp = require("gulp");
var jshint = require("gulp-jshint");
var nodemon = require("gulp-nodemon");
var shell = require("gulp-shell");
var argv = require('yargs').argv;
var fs = require("fs");
var jsFiles = ["./**/*.js", "index.js"];
var merge = require("deepmerge");
gulp.task("install", shell.task("npm install"));
gulp.task("watch", ["serve"], function () {
var watcher = gulp.watch(jsFiles, ["serve"]);
watcher.on("change", function (event) {
console.log("File " + event.path + " was " + event.type);
});
});
gulp.task("jshint", function () {
return gulp.src(jsFiles)
.pipe(jshint())
.pipe(jshint.reporter("default"))
.pipe(jshint.reporter("fail"));
});
gulp.task("config", function () {
var environment = argv.target || "dev";
console.log("writing config for %s", environment);
var configs = require("./config.js");
var defaults= configs['defaults'];
var specific= configs[environment];
var output = merge(defaults, specific);
fs.writeFileSync("config.json", JSON.stringify(output));
});
gulp.task("serve", ["config"], function () {
nodemon({
script: 'index.js',
ext: 'html js json'
})
.on("restart", function () {
console.log("nodemon - restarted!");
});
});