Skip to content

Commit

Permalink
documentation in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
e2tha-e committed Jan 28, 2019
1 parent 9667fbf commit d83e7db
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 3 deletions.
84 changes: 81 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,91 @@ This package aims to help gulp tasks coded in gulp 3 syntax run in gulp 4.
### Use

```javascript
const gulp = require('gulp');
const runSequence = require('gulp4-run-sequence');
const fs = require('fs');

// This will run in this order:
// * boil-water
// * steep-tea and boil-egg in parallel
// * peel-egg
// * Finally call the callback function
gulp.task('build', function (callback) {
runSequence(
'boil-water',
['steep-tea', 'boil-egg'],
'peel-egg',
callback
// ^^^^^^^^
// This informs that the sequence is complete.
);
});

// Configure boil-water, steep-tea, boil-egg, and peel-egg as you wish,
// but make sure they return a stream or promise, or handle the callback.
// Example:

gulp.task('boil-water', function() {
// Return the stream from gulp.
return gulp.src(water).pipe(...)...
});

gulp.task('boil-egg', function() {
return new Promise(function (resolve, reject) {
// Make sure asynchronous tasks are resolved or rejected.
});
});

gulp.task('peel-egg', function(callback) {
fs.readFile('egg', function (err, data) {
// Consume data...
callback();
// ^^^^^^^^
// This informs that the task is complete.
});
});
```

### Use within gulp submodules

If you have a complex gulp setup with your tasks split up across different
files, you may get the error that `gulp4-run-sequence` is unable to find your
tasks. In this case, you can configure `gulp4-run-sequence` to look at the gulp
within the submodule, like so:

```javascript
// Explicitly declare gulp particular to your submodule.
const gulp = require('gulp');
// Explicitly assign this gulp to gulp4-run-sequence.
const runSequence = require('gulp4-run-sequence').use(gulp);

// ...and then use normally.
gulp.task('supertask', function (callback) {
runSequence('subtask0', 'subtask1', callback);
});
```

See the gulp 3 [run-sequence docs](https://github.com/OverZealous/run-sequence)
for further documentation on usage.
### Options

The options in the gulp 3 version of run-sequence no longer apply.

`showErrorStackTrace` no longer applies because errors are handled entirely
within the gulp4 stack. A good command of streams, promises, and callback
functions will deliver the desired amount of error verbosity.

`ignoreUndefinedTasks` no longer applies because all falsey arguments will be
skipped without a warning. The logic follows the best practice of looking for
positives, rather than looking for a subset of the infinite set of negatives, in
order to warn that there's a negative, only to skip it or exit on it.

### Acknowledgements

This package is inspired entirely by
[run-sequence](https://github.com/OverZealous/run-sequence) for gulp 3. Credit
and gratitude are due for
[its contributors](https://github.com/OverZealous/run-sequence/graphs/contributors).

Also recommended: [gulp 3 with long-term support](https://github.com/electric-eloquence/gulp)
#### Also recommended: [gulp 3 with long-term support](https://github.com/electric-eloquence/gulp)

[snyk-image]: https://snyk.io/test/github/electric-eloquence/gulp4-run-sequence/master/badge.svg
[snyk-url]: https://snyk.io/test/github/electric-eloquence/gulp4-run-sequence/master
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ module.exports = runSequence.bind(null, null);
module.exports.use = function (gulp) {
return runSequence.bind(null, gulp);
};
module.exports.options = {};

0 comments on commit d83e7db

Please sign in to comment.