[英]Gulp : wait before executing next instruction
It seems that Gulp execute all instructions synchronously. Gulp似乎可以同步执行所有指令。 Because of that, I can't concat JS files first then, after, delete the JS folder. 因此,我无法先连接JS文件,然后再删除JS文件夹。
Here is my code : 这是我的代码:
gulp.task('build', function() {
// Concat JS files
gulp.src([
"www/js/navigation.js",
"www/js/initialization.js"
])
.pipe(concat('min.js'))
.pipe(gulp.dest('www'))
// Delete JS Folder
del([
'www/js/',
]);
});
When executed, I get the error : 执行时,出现错误:
> $ gulp build
> [12:18:27] Using gulpfile ~/project/gulpfile.js
> [12:18:27] Starting 'build'... [12:18:27] Finished 'build' after 13 ms
>
> events.js:72
> throw er; // Unhandled 'error' event
> ^ Error: ENOENT, open '/Users/lepix/project/www/js/initialization.js'
You should separate the tasks and call del.sync: 您应该分离任务并调用del.sync:
gulp.task('reset', function () {
return del.sync([
'www/js/'
]);
});
gulp.task('minify', function(){
gulp.src([
"www/js/navigation.js",
"www/js/initialization.js"
])
.pipe(concat('min.js'))
.pipe(gulp.dest('www'))
})
gulp.task('build', ['reset', 'minify']);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.