Drop-in replacement for
Run a sequence of tasks, in the order you specify, as part of a greater task.
(This package aims to help tasks, formerly dependent on
gulp 3, run in
const gulp = ;const runSequence = ;const fs = ;// This will run in this order:// * 'boil-water'// * 'steep-tea' and 'boil-egg' concurrently// * 'peel-egg'// * Finally, the callback function.gulp;// 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.// Examples:gulp;gulp;gulp;
If you have a complex
gulp setup, with your tasks split up across different
gulp4-run-sequence might not be able to find every task, and will error
that such tasks were never defined. In this case, you can configure
gulp4-run-sequence to look at the
gulp within the submodule, like so:
// Explicitly declare gulp particular to your submodule.const gulp = ;// Explicitly assign this gulp to gulp4-run-sequence.const runSequence = ;// ...and then use normally.gulp;
errorOnInvalidArgumentType: Set this to true in order to throw an error if an
invalid argument type has been passed. The only valid argument types are string,
array, and function.
runSequenceoptionserrorOnInvalidArgumentType = true;gulp;
The options in the
gulp 3 version of
run-sequence no longer apply.
showErrorStackTrace no longer applies because errors are handled entirely
gulp 4 stack. A good command of streams, promises, and callback
functions will deliver the desired amount of error verbosity.
ignoreUndefinedTasks no longer applies because falsy arguments will either be
skipped without warning (default behavior), or cause an error if
errorOnInvalidArgumentType is set to
Why the culinary task names?
Computational tasks might be too abstract for visualizing sequences and concurrency. It's much easier to visualize steeping tea and boiling eggs concurrently, but only after water has come to a boil.
It might also be irresponsible to suggest running certain tasks concurrently, when concurrent operation would not be optimal for those tasks.
First, we need to understand what "parallel", "concurrent", and "asynchrony" mean in terms of computing.
"Parallel" computing refers to distributing processes across multiple processor cores.
"Concurrent" computing refers to running multiple processes in such a way, that they appear to be running at the same time. This can be accomplished by rapidly switching between the processes on one processor core.
"Asynchrony" refers to when a process runs outside the main execution flow, and the main execution might need a response. If it does, it must not block other processes that don't depend on the response, while it waits.
"single-threaded". In recent years, this has become wholly untrue. If you are
not sure why you're reading this, but thanks for checking out
Now consider a procedure found in nearly every
gulp implementation: a file
read. It is not a good idea to read files concurrently on a single machine, even
if it has many processor cores. We should assume the machine has a single disk
drive, and that the drive has a single read/write head. Even if those aren't the
case, we should assume there is only one pathway open at a given time, on which
the data can travel from drive to memory.
Let's make a culinary analogy: Assume we need 2 liters of warm water evenly mixed from a cold tap and a hot tap. However, the taps are 10 meters apart. Any rational person would mix the water sequentially, filling a liter of cold water, walking the 10 meters, and filling another liter of hot water.
Trying to make this water gathering appear concurrent by filling smaller amounts of water at a time, and walking more, is called "thrashing" if applied to a disk drive!