-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
53 lines (45 loc) · 1.8 KB
/
gulpfile.js
File metadata and controls
53 lines (45 loc) · 1.8 KB
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
const { watch, src, dest, task, symlink, parallel, series } = require('gulp')
const newer = require('gulp-newer')
function setupCopier(srcGlob, destPath, onlyCheckNewer) {
let runner = function (next) {
let pipe = src(srcGlob)
if (onlyCheckNewer) pipe = pipe.pipe(newer(destPath))
pipe.pipe(dest(destPath))
return next()
}
runner.displayName = "Copy " + srcGlob
return runner
}
function setupWatcher(srcGlob, destPath) {
return watch(
srcGlob,
{ ignoreInitial: false },
setupCopier(srcGlob, destPath, true)
)
}
exports.start = task('start', (next) => {
const { spawn } = require('child_process');
const path = require('path')
let proc = spawn(path.normalize("./node_modules/.bin/vite" + (process.platform === 'win32' ? '.cmd' : '')), { cwd: 'base' })
proc.stdout.pipe(process.stdout)
proc.stderr.pipe((process.stderr))
proc.on('exit', function (code) {
console.log('child process exited with code ' + code.toString());
next()
});
})
exports.watch = task('watch', () => {
setupWatcher('content/recordings/**', 'base/public/asciinema/recordings/')
setupWatcher('content/sections/images/**', 'base/public/images/')
setupWatcher('content/sections/*.svx', 'base/src/sections/')
setupWatcher('content/pages.ts', 'base/src/')
setupWatcher('content/index.html', 'base/')
})
exports.copy = task('copy', series(
setupCopier('content/recordings/**', 'base/public/asciinema/recordings/', false),
setupCopier('content/sections/images/**', 'base/public/images/', false),
setupCopier('content/sections/*.svx', 'base/src/sections/', false),
setupCopier('content/pages.ts', 'base/src/', false),
setupCopier('content/index.html', 'base/', false)
))
exports.default = parallel('watch', 'start')