如何增加吞吐任务的堆栈跟踪? [英] how do I increase stack trace of gulp task?

查看:101
本文介绍了如何增加吞吐任务的堆栈跟踪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $ gulp patch 
[17:13:27]需要外部模块coffee-script / register
[17:13:28]使用gulpfile〜/ source /sem-campaign.js/gulpfile.coffee
[17:13:28]启动'bump'...
[17:13:28]启动'add'...
[17:13:28]将版本撞击到:1.0.2
[17:13:28]将版本撞击到:1.0.2
[17:13:28]在31 ms后完成撞击
[17:13:28]
[17:13:28] 30 ms后完成'add'
[17:13:28]开始'commit'...
[?]输入一个提交信息,例如:初始提交:初始提交
[17:13:32]在3.26 s
[17:13:32]之后完成'提交'开始'补丁'..
没有好友
[17:13:32] 25微秒后完成补丁

events.js:72
throw er; //未处理'错误'事件
^
错误:命令失败:
在ChildProcess.exithandler(child_process.js:648:15)
在ChildProcess.emit(events.js :98:17)
at MaybeClose(child_process.js:756:16)
在Socket。< anonymous> (child_process.js:969:11)
在Socket.emit(events.js:95:17)

我很难分辨出我的吞咽任务失败的原因以及原因。如何增加默认堆栈跟踪?

解决方案

添加评论和管道工:


  1. 添加这个帮手方法:

    log =(msg) - >
    console.log msg
    #你会收到乙烯基文件为块
    transform =(file,cb) - >
    #读取和修改文件内容
    #file.contents = new Buffer(String (file.contents)+'一些修改过的内容');

     #如果出现错误,只需作为第一个参数传递这里
    cb(null,file);

    #返回地图将导致您的变换函数被称为
    #您收到的块(文件)。当这个流
    #收到一个'结束'信号时,它也会结束。

    #此外,您还想在其他地方要求 event-stream
    return eventStream.map(transform);


  2. 任务中的步骤之间的管道日志方法:

    gulp.task'myTask', - >
    gulp.src myCss,
    base:myBase
    .pipe log获得了css文件!
    .pipe concat'app.css'
    .pipe logconcated css !!


这是用coffeescript编写的,你可以在这里把它变成javascript:
http://js2coffee.org/


  1. 创建catch错误帮助器方法:

    catchError =(err) - >
    plugins.util.beep()# REF ;
    console.log err


  2. 将plumber添加到插件:

    gulp.task' myTask', - >
    gulp.src myCss,
    base:myBase
    .pipe plugins.plumber
    errorHandler:catchError
    .pipe log获得了css文件!
    .pipe concat'app.css'
    .pipe logconcated css !!


完成! :)

需要更多资源:
gulp-print
gulp-debug


$ 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?

解决方案

Add comments and plumber:

  1. 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);

  2. 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/

  1. create a catch error helper method:

    catchError = (err) -> plugins.util.beep() # ref; console.log err

  2. 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

这篇关于如何增加吞吐任务的堆栈跟踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆