-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgulpfile.js
42 lines (30 loc) · 1002 Bytes
/
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
/// <binding ProjectOpened='default' />
const { watch, src, dest } = require('gulp');
var config = require('./paths.json');
// read in from the paths.json.
const sources = config.sources;
const destinations = config.destinations;
function copy(path, base) {
destinations.forEach(function (target) {
console.log(
'[\x1b[32m%s\x1b[0m] \x1b[33m%s\x1b[0m >> \x1b[34m%s\x1b[0m',
time(), path.substring(base.length + 1), target);
src(path, { base: base })
.pipe(dest(target));
});
}
function time() {
return new Date().toLocaleTimeString();
}
exports.default = function () {
sources.forEach(function (source) {
var searchPath = source + '/**/*';
watch(searchPath, { ignoreInitial: false })
.on('change', function (path, stats) {
copy(path, source);
})
.on('add', function (path, stats) {
copy(path, source);
});
});
};