gulp 4和babel 7-您是否忘记信号异步完成?

时间:2019-06-05 07:42:50

标签: javascript gulp frontend babel

我有一个非常简单的gulpfile(将其缩减为最少的最小复制情况)...

var gulp = require('gulp');
var babel = require('gulp-babel');
var log = require('fancy-log');

var scripts = {
    entry: 'temp/js/AppStart.js',
    tempIn: 'temp/js/**/*.js',
    tempOut: 'temp/js',
    dist: 'dist/js'
}

function babel() {
    return new Promise(function (resolve, reject) {
        gulp.src(scripts.tempIn)
            .pipe(babel())
            .pipe(gulp.dest(scripts.tempOut))
            .on('end', resolve)
            .on('error', (error) => {
                log(error);
                reject()
            });
    });
}

gulp.task('js:babel', babel);

运行gulp js:babel时,我得到以下输出...

PS D:\Projects\my-project\Front-End-build> gulp js:babel
[07:29:04] Using gulpfile D:\Projects\my-project\Front-End-build\gulpfile.js
[07:29:04] Starting 'js:babel'...
[07:29:04] The following tasks did not complete: js:babel
[07:29:04] Did you forget to signal async completion?

如何使它成功运行?

预先感谢

0 个答案:

没有答案