问题
$ gulp patch
[17:13:27] Requiring external module coffee-script/register
[17:13:28] Using gulpfile ~/source/sem-campaign.js/gulpfile.coffee
[17:13:28] Starting 'bump'...
[17:13:28] Starting 'add'...
[17:13:28] Bumped version to: 1.0.2
[17:13:28] Bumped version to: 1.0.2
[17:13:28] Finished 'bump' after 31 ms
[17:13:28]
[17:13:28] Finished 'add' after 30 ms
[17:13:28] Starting 'commit'...
[?] enter a commit msg, eg initial commit: initial commit
[17:13:32] Finished 'commit' after 3.26 s
[17:13:32] Starting 'patch'...
no buddy
[17:13:32] Finished 'patch' after 25 μs
events.js:72
throw er; // Unhandled 'error' event
^
Error: Command failed:
at ChildProcess.exithandler (child_process.js:648:15)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Socket.<anonymous> (child_process.js:969:11)
at Socket.emit (events.js:95:17)
It's hard for me to tell where my gulp task is failing and why. How can I increase the default stack trace?
回答1:
Add comments and plumber:
Add this helper method:
log = (msg) -> console.log msg # you're going to receive Vinyl files as chunks transform = (file, cb) -> # read and modify file contents # file.contents = new Buffer(String(file.contents) + ' some modified content');
# if there was some error, just pass as the first parameter here cb(null, file);
# returning the map will cause your transform function to be called # for each one of the chunks (files) you receive. And when this stream # receives a 'end' signal, it will end as well. # # Additionally, you want to require the
event-stream
somewhere else. return eventStream.map(transform);pipe thw log method between steps in a task:
gulp.task 'myTask', -> gulp.src myCss, base: myBase .pipe log "Got css files!" .pipe concat 'app.css' .pipe log "concated css!!"
this is written in coffeescript, you can turn it to javascript here: http://js2coffee.org/
create a catch error helper method:
catchError = (err) -> plugins.util.beep() # ref; console.log err
add plumber to plugins:
gulp.task 'myTask', -> gulp.src myCss, base: myBase .pipe plugins.plumber errorHandler: catchError .pipe log "Got css files!" .pipe concat 'app.css' .pipe log "concated css!!"
Done! :)
More resources to check out: gulp-print gulp-debug
来源:https://stackoverflow.com/questions/26197238/how-do-i-increase-stack-trace-of-gulp-task