gulpif不适用于del

时间:2014-12-06 13:15:30

标签: angularjs gulp gulp-if

使用此代码:

 global.release = argv.release;
    var gulp = require('gulp');
    var gulpif = require('gulp-if');
    var del = require('del');

    module.exports = gulp.task('clean', function (cb) {
        return gulpif(release, del([TMP_FOLDER, PHONEGAP_FOLDER],cb), del([TMP_FOLDER, BUILD_FOLDER],cb));
    });

我有这个错误:

[14:07:35] Starting 'default'...
[14:07:35] Starting 'clean'...
undefined
[14:07:35] 'clean' errored after 6.11 ms
[14:07:35] Error: gulp-if: child action is required
    at module.exports (/home/user/github/angular-bootstrap-cordova-seed/node_modules/gulp-if/index.js:10:9)
    at Gulp.<anonymous> (/home/user/github/angular-bootstrap-cordova-seed/gulp/tasks/clean.js:8:12)
    at module.exports (/home/user/github/angular-bootstrap-cordova-seed/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/home/user/github/angular-bootstrap-cordova-seed/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/home/user/github/angular-bootstrap-cordova-seed/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/home/user/github/angular-bootstrap-cordova-seed/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at runNextSet (/home/user/github/angular-bootstrap-cordova-seed/node_modules/run-sequence/index.js:74:16)
    at runSequence (/home/user/github/angular-bootstrap-cordova-seed/node_modules/run-sequence/index.js:85:2)
    at Gulp.<anonymous> (/home/user/github/angular-bootstrap-cordova-seed/gulp/tasks/default.js:15:9)
    at module.exports (/home/user/github/angular-bootstrap-cordova-seed/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
Error running task sequence: { task: 'clean',
  message: 'clean catch',
  duration: 0.006112762,
  hrDuration: [ 0, 6112762 ],
  err: [Error: gulp-if: child action is required] }
[14:07:35] Finished 'default' after 13 ms
[14:07:35] 'clean' errored after 15 ms
[14:07:35] Error: task completion callback called too many times
    at finish (/home/user/github/angular-bootstrap-cordova-seed/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:15:10)
    at cb (/home/user/github/angular-bootstrap-cordova-seed/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:29:3)
    at module.exports (/home/user/github/angular-bootstrap-cordova-seed/node_modules/del/node_modules/each-async/index.js:22:3)
    at /home/user/github/angular-bootstrap-cordova-seed/node_modules/del/index.js:34:3
    at /home/user/github/angular-bootstrap-cordova-seed/node_modules/del/node_modules/globby/node_modules/async/lib/async.js:277:13
    at /home/user/github/angular-bootstrap-cordova-seed/node_modules/del/node_modules/globby/node_modules/async/lib/async.js:157:25
    at /home/user/github/angular-bootstrap-cordova-seed/node_modules/del/node_modules/globby/node_modules/async/lib/async.js:274:17
    at /home/user/github/angular-bootstrap-cordova-seed/node_modules/del/node_modules/globby/index.js:38:4
    at f (/home/user/github/angular-bootstrap-cordova-seed/node_modules/del/node_modules/globby/node_modules/glob/node_modules/once/once.js:17:25)
    at Glob.<anonymous> (/home/user/github/angular-bootstrap-cordova-seed/node_modules/del/node_modules/globby/node_modules/glob/glob.js:129:7)
[14:07:35] 'clean' errored after 16 ms
[14:07:35] Error: task completion callback called too many times
    at finish (/home/user/github/angular-bootstrap-cordova-seed/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:15:10)
    at cb (/home/user/github/angular-bootstrap-cordova-seed/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:29:3)
    at module.exports (/home/user/github/angular-bootstrap-cordova-seed/node_modules/del/node_modules/each-async/index.js:22:3)
    at /home/user/github/angular-bootstrap-cordova-seed/node_modules/del/index.js:34:3
    at /home/user/github/angular-bootstrap-cordova-seed/node_modules/del/node_modules/globby/node_modules/async/lib/async.js:277:13
    at /home/user/github/angular-bootstrap-cordova-seed/node_modules/del/node_modules/globby/node_modules/async/lib/async.js:157:25
    at /home/user/github/angular-bootstrap-cordova-seed/node_modules/del/node_modules/globby/node_modules/async/lib/async.js:274:17
    at /home/user/github/angular-bootstrap-cordova-seed/node_modules/del/node_modules/globby/index.js:38:4
    at f (/home/user/github/angular-bootstrap-cordova-seed/node_modules/del/node_modules/globby/node_modules/glob/node_modules/once/once.js:17:25)
    at Glob.<anonymous> (/home/user/github/angular-bootstrap-cordova-seed/node_modules/del/node_modules/globby/node_modules/glob/glob.js:129:7)

这是一个错误吗? 如果不是什么事?

1 个答案:

答案 0 :(得分:2)

两个问题:

  • 你试图使用gulp-if在乙烯流之外
  • del不是gulp-plugin。

你不需要gulp-如果你的例子:

module.exports = gulp.task('clean', function(cb) {
  del(release ? [TMP_FOLDER, PHONEGAP_FOLDER] : [TMP_FOLDER, BUILD_FOLDER], cb);
});

https://github.com/robrich/gulp-if

  

三元插件:有条件地控制乙烯基物体的流动。