forked from TrackIF/auto-block
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
150 lines (116 loc) · 3.05 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
var argv = require('argv')
var gulp = require('gulp')
var babel = require('gulp-babel')
var eslint = require('gulp-eslint')
var gutil = require('gulp-util')
var colors = gutil.colors
var del = require('del')
var runSequence = require('run-sequence')
var mocha = require('gulp-spawn-mocha')
var changed = require('gulp-changed')
var args = argv
.option({
name: 'test-only',
short: 't',
type: 'string',
description: 'Only run tests containing this string',
example: "'gulp test --test-only=foo'"
})
.option({
name: 'dry-run',
type: 'boolean',
description: 'Dry run deploy flag',
example: "'gulp deploy --dry-run=false'"
})
.run()
// COMMANDS
// * These are the tasks you should call directly
// * Dependencies only (no implementation; no runSequence)
// * These are effectively aliases
gulp.task('clean', ['clean:all'])
gulp.task('nuke', ['nuke:all'])
gulp.task('build', ['build:all'])
gulp.task('test', ['test-unit:all'])
gulp.task('start', ['start:server'])
gulp.task('watch', ['watch:all'])
gulp.task('deploy', ['deploy:lambdas'])
// DEPENDENCIES
// * Defines the dependency chains
// * Dependencies can only exist between tasks in this area
// * Typically calls runSequence to :run versions of tasks
// * runSequence should *only* have calls to :run versions
// * You should never call these tasks directly
/* CLEAN */
gulp.task('clean:all', (done) => {
runSequence('clean:lib:run', done)
})
gulp.task('nuke:all', ['clean:all'], (done) => {
runSequence('clean-npm:lib:run', done)
})
/* BUILD */
gulp.task('build:all', ['build:lib'])
gulp.task('build:lib', (done) => {
runSequence('build:lib:run', done)
})
/* TEST */
gulp.task('test-unit:all', ['build:all'], (done) => {
runSequence('test-unit:lib:run', 'lint:all:run', done)
})
/* LINT */
gulp.task('lint:all', ['build:all', 'test-unit:all'], (done) => {
runSequence('lint:all:run', done)
})
// LOGIC ONLY
// * No dependencies allowed
// * No runSequence calls allowed
// * You should never call these tasks directly
/* CLEAN */
gulp.task('clean:lib:run', () => {
return del('dist')
})
gulp.task('clean-npm:lib:run', () => {
var targets = [
'node_modules'
]
return del(targets)
})
/* BUILD */
gulp.task('build:lib:run', () => {
var src = 'lib/**/*.js'
var dst = 'dist'
return gulp
.src(src)
.pipe(changed(dst))
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest(dst))
})
/* TEST */
gulp.task('test-unit:lib:run', () => {
var mochaOptions = {
cwd: 'dist'
}
if (args.options['test-only']) {
gutil.log(
colors.cyan('test-unit:lib:run') + ':',
colors.yellow('Only running tests matching'),
colors.magenta(args.options['test-only']))
mochaOptions.grep = args.options['test-only']
}
return gulp
.src('dist/**/*.spec.js', { read: false })
.pipe(mocha(mochaOptions))
})
/* LINT */
gulp.task('lint:all:run', () => {
var sources = [
'gulpfile.js',
'lib/**/*.js'
]
return gulp
.src(sources)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
})