1 |
|
2 | 'use strict';
|
3 | var gulp = require('gulp');
|
4 | var extToGlob = require('../lib/ext-to-glob');
|
5 | var unlink = require('../lib/unlink');
|
6 | var compileJson = require('../compiler/compile-json');
|
7 | var watchLog = require('../log/watch');
|
8 |
|
9 | var JSON_EXTS = ['json', 'jsonc', 'cjson', 'json5'];
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | exports.build = function (config) {
|
15 | return function () {
|
16 | return compileJson(config, extToGlob(config, JSON_EXTS));
|
17 | };
|
18 | }
|
19 |
|
20 |
|
21 |
|
22 | exports.watch = function (config) {
|
23 | return function (cb) {
|
24 | var glob = extToGlob(config, JSON_EXTS);
|
25 | watchLog('json', glob)
|
26 | gulp.watch(glob, {})
|
27 | .on('change', function (file) { return compileJson(config, file); })
|
28 | .on('add', function (file) { return compileJson(config, file); })
|
29 | .on('unlink', unlink(config.src, config.dist, '.json'))
|
30 | ;
|
31 | cb && cb();
|
32 | }
|
33 | } |
\ | No newline at end of file |