Skip to content

Commit b9fa7e0

Browse files
authored
Make eslint use async hints for gulp (#18)
* eslint task should return a stream so gulp understands it's running async; actually merge many streams since there are multiple eslints running concurrently * task definition needs to return too
1 parent 8be2ace commit b9fa7e0

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ var tasks = {
672672
},
673673

674674
lint: function() {
675-
require('./internal/lint').exec(langConfig, lintConfig);
675+
return require('./internal/lint').exec(langConfig, lintConfig);
676676
}
677677
};
678678

internal/lint.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var gulp = require('gulp');
22
var gulpIf = require('gulp-if');
3+
var merge = require('merge-stream');
34
var fs = require('fs');
45
var cwd = process.cwd();
56
var paths = require('./paths');
@@ -27,7 +28,7 @@ exports.exec = function(langConfig, lintConfig) {
2728
// with a .jshintrc file.
2829
runJsHint(lintConfig);
2930
} else {
30-
runEslint(langConfig, lintConfig);
31+
return runEslint(langConfig, lintConfig);
3132
}
3233
};
3334

@@ -52,7 +53,7 @@ function runJsHint(lintConfig) {
5253
_runJsHint(paths.srcPaths);
5354
}
5455
if (lintConfig.tests) {
55-
_runJsHint([paths.testSrcPath]);
56+
return _runJsHint([paths.testSrcPath]);
5657
}
5758
}
5859

@@ -87,6 +88,8 @@ function runEslint(langConfig, lintConfig) {
8788
return fixLint && file.eslint != null && file.eslint.fixed;
8889
}
8990

91+
var mergedStreams = merge();
92+
9093
function _runEsLint(pathSet, patterns) {
9194

9295
function getSrcPaths(path) {
@@ -99,7 +102,7 @@ function runEslint(langConfig, lintConfig) {
99102

100103
for (var i = 0; i < pathSet.length; i++) {
101104
var srcPaths = getSrcPaths(pathSet[i]);
102-
gulp.src(srcPaths)
105+
var stream = gulp.src(srcPaths)
103106
.pipe(eslint(eslintConfig))
104107
.pipe(eslint.format())
105108
.pipe(eslint.results(function (results) {
@@ -120,15 +123,19 @@ function runEslint(langConfig, lintConfig) {
120123
}
121124
}
122125
}))
123-
.pipe(gulpIf(isFixed, gulp.dest(pathSet[i])))
124-
;
126+
.pipe(gulpIf(isFixed, gulp.dest(pathSet[i])));
127+
128+
mergedStreams.add(stream);
125129
}
126130
}
131+
127132
if (lintConfig.src) {
128133
_runEsLint([cwd], ['index.js']);
129134
_runEsLint(paths.srcPaths, ['**/*.js', '**/*.jsx', '**/*.es6']);
130135
}
131136
if (lintConfig.tests) {
132137
_runEsLint([paths.testSrcPath], ['**/*.js', '**/*.jsx', '**/*.es6']);
133138
}
134-
}
139+
140+
return mergedStreams;
141+
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"handlebars": "^3.0.3",
5353
"jasmine-reporters": "^2.0.6",
5454
"jshint": "^2.x",
55+
"merge-stream": "^1.0.1",
5556
"minifyify": "^7.1.0",
5657
"ncp": "^2.0.0",
5758
"node-http-server": "^3.0.5",

0 commit comments

Comments
 (0)