-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async task with multiple gulp.src #82
Comments
@6aKa You're suggesting wrappers for This is out of scope of gulp. |
You got a problem - gult.task('cookie', function(cb) {
gulp.src('jquery.cookie/jquery.cookie.js')
.pipe(gulp.dest('public/jquery'));
});
gult.task('bootstrap', function(cb) {
gulp.src('bootstrap/js/*.js')
.pipe(gulp.dest('public/bootstrap'));
});
gulp.task('test', function() {
gulp.run('cookie', 'bootstrap');
}); But if you want shorter version of gulp.task('test', function(cb) {
gulp.src('bootstrap/js/*.js')
.pipe(gulp.dest('public/bootstrap'))
.on('end', cb);
gulp.src('jquery.cookie/jquery.cookie.js')
.pipe(gulp.dest('public/jquery'))
.on('end', cb);
}); |
@dashed I suggest aliases. For example I use many variables, and path.join for src and dest. Gulpfile look likes from hell. And because, I want many short constructions, aliases :) @floatdrop Split for individual task more accurate, but ugly if you copy many dependencies to work directory. I want true async tasks, with multiple gulp.src inside, without |
Should gulp warn you or error if you call |
@6aKa maybe with event-stream.concat this will look nicer: var es = require('event-stream');
gulp.task('test', function(cb) {
es.concat(
gulp.src('bootstrap/js/*.js')
.pipe(gulp.dest('public/bootstrap')),
gulp.src('jquery.cookie/jquery.cookie.js')
.pipe(gulp.dest('public/jquery'))
).on('end', cb);
}); |
There should be a wiki page to hold all the neat usage patterns of gulp. Some of the interesting ones usually get buried in github issues. |
@robrich for errors I have event 'error' and can catch with .on('error', cb). I like ideas for gulp.task('test', function(cb) { async.series([ gulp.src('bootstrap/js/*.js') .pipe(gulp.dest('public/bootstrap')) .on('error', callback(err, 'one')) .on('end', callback(null, 'one')); gulp.src('jquery.cookie/jquery.cookie.js') .pipe(gulp.dest('public/jquery')) .on('error', callback(err, 'two')) .on('end', callback(null, 'two');); ], function (err, result) { }); }); @floatdrop concat with event-stream look very good. I think this trick should be added to wiki :) |
@floatdrop perfect - just what that section was for |
You can actually just return the es.concat stream btw - no need to listen for end or error events since the task system already does that if you return a stream from a task |
Thanks @contra ! It also make mocha gist shorter! |
You can use merge-stream
|
I do it like this: gulp.task('publish', function(cb) {
async.series([
function (callback) {
gulp.src('css/*.css')
.pipe(minifyCss())
.pipe(rev())
.pipe(gulp.dest('public/css'))
.pipe( rev.manifest() )
.pipe( gulp.dest( 'rev/css' ) )
.on('end', callback);
},
function (callback) {
gulp.src('js/*.js')
.pipe(jshint())
.pipe(uglify())
.pipe(rev())
.pipe(gulp.dest('public/js'))
.pipe( rev.manifest() )
.pipe( gulp.dest( 'rev/js' ) )
.on('end', callback);
}
,
function (callback) {
gulp.src('images/*')
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest('public/img'))
.on('end', callback);
}
],
function (err, values) {
if (err) {
cb('your error');
}
else
{
console.log('success');
cb();
//process.exit();
}
});
});
gulp.task('default', ['publish']); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Do not restart an issue thread from 4 years ago. |
it's better, IMHO, that the information regarding this question will be here than scattered around the internet, so others will easily access it and gain insights. |
|
@robrich - This why would I want to load such enormous package for something so simple like I showed in my code comment above? |
This comment has been minimized.
This comment has been minimized.
@robrich you're right, it's getting locked because you are so misinformed about where gulp is now. We even have tight integration with async/await |
Example, with useing callback
Please add method for event 'end'. Like this
And for 'error' and 'data' events.
The text was updated successfully, but these errors were encountered: