对于 “停止和故障” 部分:
这里是jshint的功能例如:
var reporter = require('jshint-stylish');
var jshintRc = readJSON('.jshintrc');
// Implement asynchronous support returning the stream
gulp.task('myhinter', function() {
// All js in src
return gulp.src('./src/*.js')
// options from file
.pipe(jshint(jshintRc))
// like stylish reporter
.pipe(jshint.reporter(reporter))
// Our turn!
.pipe(map(function (file, cb) {
// Notify the callback "true" if it failed on the file
cb(!file.jshint.success, file);
}));
})
// Now, define thattask to depend on myhinter
gulp.task('thattask', ['myhinter'], function(e) {
console.warn('thattask is executing');
});
thattask
取决于任务myhinter
的成功。
反过来,myhinter会对文件做jshint,记者使用时尚,如果至少有一个文件无法提示,则失败。
在这里,这是通过从myhinter任务返回流实现的。
你可以看到更多的是Orchestrator文档中:https://github.com/robrich/orchestrator
我不使用摩卡,但看看后来就来看看如何做到这一点。
关于打开的文件太多,在OSX上?如果是这样,可能会看到this here,如果它有帮助。
这不是一个直接的答案。你应该尽可能地尝试不打击吞咽的异步行为。大多数情况下,你可能只想连续在同一个文件上运行一堆任务。在这种情况下,您应该完成一项任务,而不是依赖临时文件。 –
这个问题并不是针对对抗异步执行,而是针对任务依赖关系的合理需求(请参阅https://github.com/gulpjs/gulp/blob/master/docs/API.md#gulptaskname-deps- fn) - 以及如何让jshint实际上失败。 OP甚至没有提到临时文件... –
Smashing杂志最近发布了一个关于[使用Gulp]的方便指南(http://www.smashingmagazine.com/2014/06/11/building-with-gulp),你可能会发现像我一样有用。 – idleberg