-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
65 lines (56 loc) · 1.87 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
var gulp = require('gulp'),
gutil = require('gulp-util'),
jshint = require('gulp-jshint'),
jshintStylish = require('jshint-stylish'),
mocha = require('gulp-mocha'),
complexity = require('gulp-complexity'),
exec = require('child_process').exec,
bump = require('gulp-bump'),
debug = require('gulp-debug'),
argv = require('minimist')(process.argv.slice(3));
gulp.task('complexity', function () {
return gulp.src('lib/**/*.js')
.pipe(complexity({
cyclomatic: [5],
halstead: [16],
maintainability: [100]
}));
});
gulp.task('lint', function () {
gulp.src(['gulpfile.js', 'lib/**/*.js', 'test/**/*.js'])
.pipe(jshint())
.pipe(jshint.reporter(jshintStylish))
.pipe(jshint.reporter('fail'));
});
gulp.task('test-unit', function () {
return gulp.src('test/unit/*.js', { read: false })
.pipe(mocha({
reporter: 'spec',
bail: false
}));
});
gulp.task('test', [ 'test-unit' ], function () {
return gulp.src('test/e2e/*.js', { read: false })
.pipe(mocha({
reporter: 'spec',
bail: false
}));
});
gulp.task('bump', function () {
var packageFile = "./package.json";
gulp.src(packageFile)
.pipe(bump({ type: argv.type || 'build'}))
.pipe(gulp.dest('./'))
.on('end', function () {
var newVersion = require(packageFile).version;
exec('git commit -am "' + newVersion + '"; git tag ' + newVersion + '; git push --tags; git push', {}, function (err, stdout, stderr) {
if (err) throw err;
gutil.log(stdout, stderr);
});
});
});
gulp.task('tdd-watch', function () {
gulp.watch([ 'lib/*.js', 'test/**/*.js' ], [ 'test' ]);
});
gulp.task('default', [ 'lint', 'test' ]);
gulp.task('tdd', [ 'test', 'tdd-watch' ]);