-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
30 lines (24 loc) · 835 Bytes
/
gulpfile.js
File metadata and controls
30 lines (24 loc) · 835 Bytes
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
const cache = require('gulp-cached');
const eslint = require('gulp-eslint');
const { spawn } = require('child_process');
const { src, watch, parallel } = require('gulp');
const { log } = console;
let node;
const server = async () => {
if (node) node.kill();
node = await spawn('node', ['src/index.js'], { 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(['src/**/*.js'])
.pipe(cache('lint'))
.pipe(eslint())
.pipe(eslint.format());
const serve = () => watch(['src/**/*.js'], { queue: false, ignoreInitial: false }, parallel(lint, server));
exports.lint = lint;
exports.serve = serve;
exports.default = serve;