1 |
|
2 | "use strict";
|
3 | var gulp = require("gulp");
|
4 | var fs = require("fs");
|
5 | var path = require("path");
|
6 | var compileJs = require("../compiler/compile-javascript");
|
7 | var unlink = require("../lib/unlink");
|
8 | var extToGlob = require("../lib/ext-to-glob");
|
9 | var watchLog = require("../log/watch");
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | exports.build = function (config, JS_EXTS) {
|
17 | return function () {
|
18 | return compileJs(config, extToGlob(config, JS_EXTS));
|
19 | };
|
20 | };
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | exports.watch = function (config, JS_EXTS) {
|
28 | return function (cb) {
|
29 | var glob = extToGlob(config, JS_EXTS);
|
30 | watchLog("javascript-" + JS_EXTS.join('-'), glob);
|
31 | gulp.watch(glob)
|
32 | .on("change", function (file) {
|
33 | return compileJs(config, file);
|
34 | })
|
35 | .on("add", function (file) {
|
36 | return compileJs(config, file);
|
37 | })
|
38 | .on("unlink", unlink(config.src, config.dist, ".js"));
|
39 | cb && cb();
|
40 | };
|
41 | };
|