This repository has been archived by the owner on Apr 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
62 lines (58 loc) · 1.41 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
58
59
60
61
62
const gulp = require('gulp')
const eslint = require('gulp-eslint')
const { exec, execSync, fork } = require('child_process')
gulp.task('lint-es6', function () {
return gulp.src([
'./**/*.js',
'!node_modules/**/*.js',
'!.next/**/*.js',
'!server.js',
'!tools/routes.js',
'!gulpfile.js',
'!tests/**/*.js',
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
})
gulp.task('lint-node', function () {
return gulp.src([
'server.js',
'tools/routes.js',
'tools/api-route/index.js',
])
.pipe(eslint({
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
},
"extends": "eslint:recommended"
}))
.pipe(eslint.format())
.pipe(eslint.failAfterError())
})
gulp.task('default', [
'lint-es6',
'lint-node'
])
gulp.task('test', function () {
return new Promise((resolve, reject) => {
exec('npm run build', { maxBuffer: 1024 * 1024 }, (err) => {
if (err) {
console.log(err)
reject(err)
return
}
var env = Object.create(process.env)
env.NODE_ENV = 'production'
const server = fork('./server.js', { env, maxBuffer: 1024 * 1024 })
server.on('message', (m) => {
if (m === 'http ready') {
execSync('npm run jest', { maxBuffer: 1024 * 1024, stdio: [0, 1, 2] })
server.kill()
resolve()
}
})
})
})
});