-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgulpfile.js
69 lines (57 loc) · 1.44 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
'use strict';
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
gutil = require('gulp-util'),
mocha = require('gulp-mocha'),
shrinkwrap = require('gulp-shrinkwrap'),
nicePackage = require('gulp-nice-package');
require('gulp-help')(gulp);
function errorLogger(err) {
gutil.beep();
gutil.log(err.message);
}
function lint() {
return gulp.src([
'./*.js',
'./test/**/*.js'
])
.pipe(jshint('./lint/.jshintrc'))
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'))
.on('error', errorLogger);
}
function test() {
return gulp.src([
'./test/**/*.js',
'!./test/helper/**'
])
.pipe(mocha({reporter: 'dot'}))
.on('error', errorLogger);
}
gulp.task('lint', function () {
return lint();
});
gulp.task('test', ['lint'], function () {
return test();
});
// when watching, do NOT return the stream, otherwise watch won't continue on error
gulp.task('lint-watch', false, function () {
lint();
});
gulp.task('test-watch', false, ['lint-watch'], function () {
test();
});
gulp.task('watch', function () {
gulp.watch([
'./*.js',
'./test/**/*.js'
], ['test-watch']);
});
gulp.task('ci', 'Run all tests and lint.', ['test']);
gulp.task('shrinkwrap', 'Cleans package.json deps and generates npm-shrinkwrap.json', function () {
return gulp.src('package.json')
.pipe(nicePackage())
.pipe(shrinkwrap())
.pipe(gulp.dest('./'));
});