Reputation: 251
I need to run one gulp task that contains 3 or 4 another tasks. The problem is (steps):
This is my code:
var gulp = require('gulp'),
decompress = require('gulp-decompress'),
download = require("gulp-download"),
ftp = require('gulp-ftp'),
gutil = require('gulp-util');
gulp.task('default', function(){
console.log("Hello gulp");
});
var src_download = [
"https://wordpress.org/latest.zip"
];
gulp.task('download', function(){
download(src_download)
.pipe(gulp.dest("./"));
});
gulp.task('unzip-wp', function(){
return gulp.src('latest.zip')
.pipe(decompress({strip: 1}))
.pipe(gulp.dest('./'));
});
gulp.task('install', ['download', 'unzip-wp']);
As you can see, when I am trying to run 'install' task - it will run 'unzip-wp' before 'download' has been completed...
What am I doing wrong?
I need to run 'unzip-wp' task only after 'download' task has been completed.
Thanks
Upvotes: 1
Views: 1412
Reputation: 4922
Very simple there is no need of unzip task it will also unzip into wordpress folder for the sake that it will not mess your other files.
gulp.task('download', function(){
download(src_download)
.pipe(decompress({strip: 1}))
.pipe(gulp.dest('./wordpress'));
});
gulp.task('default', ['download']);
Upvotes: 0
Reputation: 5095
You should have the 'unzip-wp' task wait for the 'download' task to finish. To make sure the 'download' task is really finished also add a return statement to that task, i.e. this would do what you're looking for:
var gulp = require('gulp'),
decompress = require('gulp-decompress'),
download = require("gulp-download"),
ftp = require('gulp-ftp'),
gutil = require('gulp-util');
gulp.task('default', function () {
console.log("Hello gulp");
});
var src_download = [
"https://wordpress.org/latest.zip"
];
gulp.task('download', function () {
return download(src_download)
.pipe(gulp.dest("./"));
});
gulp.task('unzip-wp', ['download'], function () {
return gulp.src('latest.zip')
.pipe(decompress({strip: 1}))
.pipe(gulp.dest('./'));
});
gulp.task('install', ['unzip-wp']);
Upvotes: 4