V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
wtz
V2EX  ›  前端开发

gulp 中有没有办法监听 task 执行成功或者失败的状态

  •  
  •   wtz · 2015-06-30 10:27:38 +08:00 · 2133 次点击
    这是一个创建于 3245 天前的主题,其中的信息可能已经有所发展或是发生改变。

    代码如下:
    gulp.task('copyfonts',function(){
    return gulp.src(staticConfig['fonts'] + '/')
    .pipe(gulp.dest('./dist/fonts/'));
    })

    然后我想监控 copyfonts 任务是否成功
    gulp.task('aaa', ['copyfonts'],function(err){
    console.log(err)
    });

    此时没有输出

    假如改成一个不存在地址:
    gulp.task('copyfonts',function(){
    return gulp.src(staticConfig['foxxxnts'] + '/')
    .pipe(gulp.dest('./dist/fonts/'));
    })

    还是没有输出!

    问题是如何监控copyfonts 是否成功执行??

    1 条回复    2015-06-30 11:02:54 +08:00
    yangg
        1
    yangg  
       2015-06-30 11:02:54 +08:00
    一般的任务不检测,这种从配置中读的手动检测

    if(!fs.existsSync(cwd + f)) {
    throw new Error('File not found "' + cwd + f + '"');
    }
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   904 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 22:08 · PVG 06:08 · LAX 15:08 · JFK 18:08
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.