forked from electerm/electerm-locales
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
57 lines (52 loc) · 1.43 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
const gulp = require('gulp')
const syncy = require('syncy')
const { syncTo } = require('./config.default')
const mkdirp = require('mkdirp')
const fs = require('fs')
const watch = require('gulp-watch')
console.log('syncTo', syncTo)
gulp.task('sync', function (done) {
try {
let state = fs.statSync(syncTo)
if (!state.isDirectory()) {
mkdirp(syncTo)
}
} catch (e) {
console.log(e)
mkdirp(syncTo)
}
syncy([
'./locales/*',
'./package.js*'
], syncTo, {
// // Display log messages when copying and removing files
verbose: true
// // Or create your own function.
// verbose: (stamp) => {
// // action - `copy` or `remove`
// // to - only for `copy` action
// console.log(stamp.action + ' | ' + stamp.from + ' | ' + stamp.to);
// },
// The base path to be removed from the path. Default: none
// base: 'base_path',
// Remove all files from dest that are not found in src. Default: true
// updateAndDelete: true,
// Never remove js files from destination. Default: false
// ignoreInDest: './src/**/*'
})
.then(() => {
console.log('sync ok')
done()
})
.catch(e => {
console.log(e)
done()
})
})
gulp.task('watch-extend', function () {
watch(['./locales/*', './package.js*'], function () {
gulp.task('sync')
})
})
gulp.task('watch', gulp.series('watch-extend'))
gulp.task('default', gulp.series('sync', 'watch'))