如果JSHint中存在错误,我希望我的Gulp构建失败.
根据gulp-jshint的文档,我可以使用"失败的记者".
但是以下不起作用:
gulp.task("lint", function() {
return gulp.src(JS_SOURCES)
.pipe(jshint())
.pipe(jshint.reporter("jshint-stylish"))
.pipe(jshint.reporter("fail"));
});
Run Code Online (Sandbox Code Playgroud)
即使JSHint中存在错误,上面的任务也始终以退出代码0返回.
我正在使用gulp 3.8.10和gulp-jshint 1.9.0.
gulp-jshint的github问题在这里和这里有讨论......但根据这些讨论,我认为上面的代码应该与gulp和gulp-jshint的最新版本一起使用.但是它不......
有没有人想过如何使用gulp-jshint正确地使构建失败?
有gulp-requirejs插件,但它被列入黑名单,并显示以下消息:" 直接使用require.js模块".
文档非常稀疏,我如何最好地将它与Gulp构建任务结合使用?
在文档中有一个例子:
var requirejs = require('requirejs');
var config = {
baseUrl: '../appDir/scripts',
name: 'main',
out: '../build/main-built.js'
};
requirejs.optimize(config, function (buildResponse) {
//buildResponse is just a text output of the modules
//included. Load the built file for the contents.
//Use config.out to get the optimized file contents.
var contents = fs.readFileSync(config.out, 'utf8');
}, function(err) {
//optimization err callback
});
Run Code Online (Sandbox Code Playgroud)
但这对我没什么帮助......这是我最好的尝试:
var gulp = require('gulp'),
r = require('requirejs').optimize;
var config2 = { …Run Code Online (Sandbox Code Playgroud)