Comments (6)
You can add dep when define a task.
g.task('copy', ['clean'], function() {
});
from gulp.
Tasks run with maximum concurrency.
What you actually want is:
var g = require('gulp');
var util = require('util');
g.task('clean', function(cb) {
setTimeout(function() {
util.log('clean task executed.');
cb(null);
}, 3000);
});
g.task('copy', ['clean'], function(cb) {
util.log('copy task executed.');
cb();
});
g.task('default', ['clean', 'copy'], function() {
util.log('default task executed.');
});
Notice the only change is making copy
depend on clean
from gulp.
I agree, the docs need work here. By default, the tasks run with maximum concurrency -- e.g. it launches all the tasks at once and waits for nothing. If you want to create a series where tasks run in a particular order, you need to do two things: give it a hint to tell it when the task is done, and give it a hint that a task depends on completion of another.
For these examples, let's presume you have two tasks, "one" and "two" that you specifically want to run in this order:
- In task "one" you add a hint to tell it when the task is done. Either take in a callback and call it when you're done or return a promise or stream that the engine should wait to resolve or end respectively.
- In task "two" you add a hint telling the engine that it depends on completion of the first task.
So this example would look like this:
var gulp = require('gulp');
// takes in a callback so the engine knows when it'll be done
gulp.task('one', function (cb) {
// do stuff -- async or otherwise
cb(err); // if you pass non-null, non-undefined, gulp will stop, and note that the build failed
});
// identifies a dependent task must be complete before this one begins
gulp.task('two', ['one'], function () {
// task 'one' is done now
});
from gulp.
thank you robrich, that was what I was looking for
from gulp.
Just a quick note:
When doing things in a stream, this seems to work great for me:
gulp.task('do-stuff', function (done) {
gulp.src(someFiles)
.pipe(doStuffToThem())
.on('end', function () { done(); });
});
from gulp.
I guess there is no way to use on the task, that has a dependency the returned stream of that dependency?
from gulp.
Related Issues (20)
- using series with ESM syntax fails? HOT 1
- Dependency vulnerability : SNYK-JS-UNSETVALUE-2400660
- gulp build heap out of memory HOT 2
- Gulp serve hangs on "configure-webpack" HOT 2
- Gulp links to protestware - blocks pipelines HOT 1
- TypeScript Module `gulpfile.mts` Not Supported HOT 2
- `npm audit` vulnerability for `glob-parent` package
- Watchers do not detect specific files
- Curly braces in glob without commas do not work HOT 2
- unlink not work HOT 2
- Dependency unset-value has a Prototype Pollution vulnerability
- Upgrade Gupl-cli version to 2.3.0 HOT 1
- gulp.src *.123456 vs *.1234567
- error TS2305: Module '"gulp"' has no exported member 'parallel' HOT 2
- Atualizacao Gulp Util
- gulp does not work if base path has brackets [ ] HOT 1
- Bump glob-watcher to 6.0.0
- Update glob-version to lates major version HOT 1
- Error: Cannot find module 'gulp-cli' HOT 2
- Bun support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp.