gulp 代码:
gulp.task('js', function() {
var condition;
var jsDest = './public/javascript/dest';
var stream = gulp.src(paths.js)
.pipe(plumber({
errorHandler: notify.onError('Message:\n\t<%= error.message %>\nDetails:\n\tlineNumber: <%= error.lineNumber %>')
}))
.pipe(jshint())
.pipe(notify(function(file) {
if ( file.jshint.success ) {
condition = true;
return false;
}
condition = false;
var errors = file.jshint.results.map(function(data) {
if ( data.error ) {
return 'line ' + data.error.line + ', col ' + data.error.character + ', ' + data.error.reason;
}
}).join('\n');
return file.relative + ' (' + file.jshint.results.length + ' errors)\n' + errors;
}))
.pipe(uglify())
.pipe(rename({
extname: '.min.js'
}))
.pipe(gulp.dest(jsDest))
.pipe(livereload())
.pipe(gulpif(condition, notify('Js: done -> <%= file.relative %>!'))); //这句话证明是无效的,为什么呢?无法达到实际的效果。。。
return stream;
});
错误信息:
gujunmin@www:~/projects/forms-authentication$ gulp
[09:50:02] Using gulpfile ~/projects/forms-authentication/gulpfile.js
[09:50:02] Starting 'jade'...
[09:50:02] Starting 'css'...
[09:50:02] Starting 'js'...
Transformers.markdown is deprecated, you must replace the :markdown jade filter, with :marked and install jstransformer-marked before you update to jade@2.0.0.
[09:50:03] Finished 'jade' after 836 ms
[09:50:03] Finished 'js' after 824 ms
[09:50:03] Finished 'css' after 880 ms
[09:50:03] Starting 'default'...
[09:50:03] Finished 'default' after 84 ms
File /home/gujunmin/projects/forms-authentication/public/javascript/src/lm.js was changed, task runnning...
[09:50:16] Starting 'js'...
[09:50:16] gulp-notify: [Gulp notification] lm.js (1 errors)
line 10, col 22, Missing semicolon.
[09:50:16] /home/gujunmin/projects/forms-authentication/public/javascript/dest/lm.min.js reloaded.
[09:50:16] Finished 'js' after 317 ms
有错误的时候,才有显示错误。没有错误的时候什么都没有显示。
请各位指教,O(∩_∩)O谢谢