forked from AlbertoElias/gulp-lintspaces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
42 lines (39 loc) · 896 Bytes
/
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
var
util = require('util'),
gulp = require('gulp'),
colors = require('ansi-colors'),
jshint = require('gulp-jshint'),
jscs = require('gulp-jscs'),
map = require('map-stream'),
jshintErrors = []
;
gulp.task('lint', function() {
return gulp
.src([
__filename,
'./index.js',
'./test/**/test_*.js'
])
.pipe(jshint())
.pipe(map(function (file, cb) {
if (file.jshint && !file.jshint.success) {
jshintErrors.push.apply(jshintErrors, file.jshint.results);
}
cb(null, file);
}))
.pipe(jscs(__dirname + '/.jscs.json'));
});
gulp.task('default', ['lint'], function() {
if (jshintErrors.length) {
console.error(jshintErrors.map(function(error) {
return util.format(
'[%s] %s in (%s:%d)\n',
colors.green('gulp-jshint'),
colors.red(error.error.reason),
error.file,
error.error.line
);
}).join(''));
process.exit(1);
}
});