-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
59 lines (46 loc) · 1.17 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
// for single build and run: `gulp build run`
// for auto rebuild and rerun: `gulp build run --watch`
'use strict'
var gulp = require('gulp')
var spawn = require('child_process').spawn
var gutil = require('gulp-util')
var babelCmdArgs = [
'src',
'--out-dir', 'dist',
'--presets', 'es2015,stage-0',
'--copy-files',
]
if (gutil.env.watch) {
gulp.task('build', ['_compile-watch'])
gulp.task('run', ['_run-watch'])
} else {
gulp.task('build', ['_compile'])
gulp.task('run', ['_run'])
}
gulp.task('_compile', function(cb) {
// note: `.cmd` extensions are required under Windows due to Node bug:
spawn('babel.cmd', babelCmdArgs, {stdio: 'inherit'})
.on('close', cb)
.on('error', cb)
})
gulp.task('_run', ['_compile'], function(cb) {
spawn('node', ['dist/index.js'], {stdio: 'inherit'})
.on('close', cb)
.on('error', cb)
})
gulp.task('_compile-watch', function(cb) {
spawn(
'babel.cmd',
babelCmdArgs.concat('--watch'),
{stdio: 'inherit'}
)
.on('error', cb)
})
gulp.task('_run-watch', ['_compile'], function(cb) {
spawn(
'nodemon.cmd',
['dist/index.js', '--watch', 'dist'],
{stdio: 'inherit'}
)
.on('error', cb)
})