From c4305df006d8c9acc915a8ccc82495cd17ca2f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Marohni=C4=87?= Date: Wed, 7 Oct 2020 23:09:03 +0200 Subject: [PATCH] Docs: Remove recipe for running tasks in series gulp v4 supports this natively, as explained in the recipe itself, so there is no need for it. --- docs/recipes/README.md | 1 - docs/recipes/running-tasks-in-series.md | 89 ------------------------- 2 files changed, 90 deletions(-) delete mode 100644 docs/recipes/running-tasks-in-series.md diff --git a/docs/recipes/README.md b/docs/recipes/README.md index e38f26e46..10ca6a120 100644 --- a/docs/recipes/README.md +++ b/docs/recipes/README.md @@ -9,7 +9,6 @@ * [Mocha test-runner with gulp](mocha-test-runner-with-gulp.md) * [Pass parameters from the command line](pass-arguments-from-cli.md) * [Generating a file per folder](running-task-steps-per-folder.md) -* [Running tasks in series](running-tasks-in-series.md) * [Server with live-reloading and CSS injection](server-with-livereload-and-css-injection.md) * [Sharing streams with stream factories](sharing-streams-with-stream-factories.md) * [Specifying a new cwd (current working directory)](specifying-a-cwd.md) diff --git a/docs/recipes/running-tasks-in-series.md b/docs/recipes/running-tasks-in-series.md deleted file mode 100644 index b28e692a3..000000000 --- a/docs/recipes/running-tasks-in-series.md +++ /dev/null @@ -1,89 +0,0 @@ -# Running tasks in series - -By default, gulp CLI run tasks 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 should use `gulp.series`; - -```js -var gulp = require('gulp'); -var doAsyncStuff = require('./stuff'); - -gulp.task('one', function(done) { - doAsyncStuff(function(err){ - done(err); - }); -}); - -gulp.task('two', function(done) { - // do things - done(); -}); - -gulp.task('default', gulp.series('one', 'two')); -``` - -Another example, using a dependency pattern. It uses -[`async-once`](https://www.npmjs.com/package/async-once) to run the `clean` -task operations only once: -```js -var gulp = require('gulp'); -var del = require('del'); // rm -rf -var once = require('async-once'); - -gulp.task('clean', once(function(done) { - // run only once. - // for the next call to the clean task, once will call done with - // the same arguments as the first call. - del(['output'], done); -})); - -gulp.task('templates', gulp.series('clean', function() { - return gulp.src(['src/templates/*.hbs']) - // do some concatenation, minification, etc. - .pipe(gulp.dest('output/templates/')); -})); - -gulp.task('styles', gulp.series('clean', function() { - return gulp.src(['src/styles/app.less']) - // do some hinting, minification, etc. - .pipe(gulp.dest('output/css/app.css')); -})); - -// templates and styles will be processed in parallel. -// `clean` will be guaranteed to complete before either start. -// `clean` operations will not be run twice, -// even though it is called as a dependency twice. -gulp.task('build', gulp.parallel('templates', 'styles')); - -// an alias. -gulp.task('default', gulp.parallel('build')); -``` - -Note that it's an anti-pattern in Gulp 4 and the logs will show the clean task -running twice. Instead, `templates` and `style` should use dedicated `clean:*` -tasks: -```js -var gulp = require('gulp'); -var del = require('del'); - -gulp.task('clean:templates', function() { - return del(['output/templates/']); -}); - -gulp.task('templates', gulp.series('clean:templates', function() { - return gulp.src(['src/templates/*.hbs']) - .pipe(gulp.dest('output/templates/')); -}); - -gulp.task('clean:styles', function() { - return del(['output/css/']); -}); - -gulp.task('styles', gulp.series('clean:styles', function() { - return gulp.src(['src/styles/app.less']) - .pipe(gulp.dest('output/css/app.css')); -})); - -gulp.task('build', gulp.parallel('templates', 'styles')); -gulp.task('default', gulp.parallel('build')); -```