forked from kevinohara80/nforce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
53 lines (43 loc) · 1.1 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
var gulp = require('gulp');
var seq = require('run-sequence');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var spawn = require('child_process').spawn;
var files = {
js: [
'./*.js',
'./lib/*.js',
'./test/*.js',
'./examples/*.js'
]
};
// run jshint tasks across all js files
gulp.task('lint', function() {
return gulp.src(files.js)
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
// run mocha tests
gulp.task('test', function(cb) {
var pkg = require('./package.json');
if(!pkg || !pkg.scripts || !pkg.scripts.test) {
return cb(new Error('No test script provided in package.json'));
}
var args = pkg.scripts.test.split(' ');
var cmd = args.shift();
var test = spawn(cmd, args, { stdio: 'inherit' });
test.on('close', function(code) {
if(code !== 0) {
return cb(new Error('mocha test failures'));
}
cb();
});
});
// set up a file watcher and run jshint
gulp.task('watch', function() {
gulp.watch(files.js, ['lint']);
});
// default task
gulp.task('default', function(cb) {
seq('lint', 'test', cb);
});