【问题标题】:gulp quitting after dependent taskgulp 在依赖任务后退出
【发布时间】:2016-06-18 00:46:04
【问题描述】:

我错过了什么?在我的依赖任务之后,Gulp 正在退出没有错误stylesstyles-clean 之后不会继续:

var args = require('yargs').argv;
var config = require('./gulp.config')();
var del = require('del');
var gulp = require('gulp');
var $ = require('gulp-load-plugins')({lazy: true});

gulp.task('styles', ['clean-styles'], function() {
  log('Compiling less...');
  return gulp
      .src(config.less)
      .pipe($.less())
      .on('error', errorLogger)
      .pipe($.autoprefixer({browsers: ['last 2 version', '> 5%']}))
      .pipe(gulp.dest(config.temp));
});

gulp.task('clean-styles', function(done){
  var files = config.temp + '**/*.css';
  clean(files, done);
});

// -------------
function errorLogger(error) {
  log(error);
}
function clean(path, done) {
  log('Cleaning: ' + $.util.colors.blue(path));
  del(path, done);
}
function log(msg) {
  if (typeof(msg) === 'object') {
    for (var item in msg) {
      if (msg.hasOwnProperty(item)) {
        $.util.log($.util.colors.blue(msg[item]));
      }
    }
  } else {
    $.util.log($.util.colors.blue(msg));
  }
}

我已经检查了我的gulpfile(上图)和我的配置:

module.exports = function () {
  var config = {
    temp: './temp/',
    alljs: [
      './src/**/*.js',
      './*.js'
    ],
    less: './src/client/styles/styles.less'
  };
  return config;
};

【问题讨论】:

    标签: node.js gulp


    【解决方案1】:

    想想你说的话。如果clean() 正在停止该进程,那么这[最有可能] 是您的问题所在。

    在这种情况下,您的问题是因为 done 回调。从 v2.0 开始,del 包不再接受回调......所以它永远不会被调用。相反,它返回一个承诺。这是文档...

    https://github.com/sindresorhus/del/releases/tag/v2.0.0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-11
      • 2016-08-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多