forked from parameter1/base-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
45 lines (39 loc) · 982 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
42
43
44
45
const {
task,
watch,
src,
parallel,
} = require('gulp');
const eslint = require('gulp-eslint');
const cache = require('gulp-cached');
const { spawn } = require('child_process');
const { log } = console;
// Common gulpfile factory. Should be used by individual packages.
module.exports = ({
entry,
watchPaths,
lintPaths,
} = {}) => {
let node;
const serve = async () => {
if (node) node.kill();
node = await spawn('node', [entry], { stdio: 'inherit' });
node.on('close', (code, signal) => {
const exited = [];
if (code) exited.push(`code ${(code)}`);
if (signal) exited.push(`signal ${(signal)}`);
log(`Process ${('exited')} with ${exited.join(' ')}`);
});
};
const lint = () => src(lintPaths)
.pipe(cache('lint'))
.pipe(eslint())
.pipe(eslint.format());
task('default', () => {
watch(
watchPaths,
{ queue: false, ignoreInitial: false },
parallel([serve, lint]),
);
});
};