I have 3 tasks that I want to handle, and when these 3 tasks are completed, I want to do the following:
- Align the three files together
- to mutilate
- Burning to disc
With Grunt , I had a long process for all this. Here is what I tried with Gulp
gulp.task('libs', function () { return gulp.src('js/libs/*.js') .pipe(concat('01.libs.js', {newLine: ';'})) .pipe(gulp.dest('min')); }); gulp.task('plugins', function () { return gulp.src('js/plugins/*.js') .pipe(concat('02.plugins.js', {newLine: ';'})) .pipe(gulp.dest('min')); }); gulp.task('apps', function () { return gulp.src('js/apps/**/*.js') .pipe(concat('03.apps.js', {newLine: ';'})) .pipe(gulp.dest('min')); }); gulp.task('scripts', ['libs', 'plugins', 'apps'], function () { return gulp .src('min/*.js') .pipe(concat('testFile.js', {newLine: ';\r\n'})) .pipe(rename({suffix: '.min.v' + pkg.version })) .pipe(gulp.dest('min')) .pipe(notify({ message: 'Scripts minified'})); });
This works, but I just want to pass the result, and not write out only 3 intermediate files, so that I can contact them later.
So then I tried:
function libs () { return gulp.src('js/libs/*.js') .pipe(concat('01.libs.js', {newLine: ';'})); } function plugins () { return gulp.src('js/plugins/*.js') .pipe(concat('02.plugins.js', {newLine: ';'})); } function apps () { return gulp.src('js/apps/**/*.js') .pipe(concat('03.apps.js', {newLine: ';'})); }
So my build will be:
gulp.task('build', function () { return libs() .pipe(plugins()) .pipe(apps()) .pipe(concat('TestFile.js', {newLine: ';\r\n'})) .pipe(rename({suffix: '.min.v' + pkg.version })) .pipe(gulp.dest('min')); });
This does not work.
So I tried Q :
function allOfThem () { return Q.all(libs(), plugins(), apps()); } gulp.task('build', function () { return allOfThem().then(function (one, two, three) { console.log(one, two, three); }); });
This, I think, works, but there is no data in the callback for then .
I'm lost. What is the best way to achieve this?