Build automation in JavaScript has gotten too complicated. It's time to bring it back to simple terminal commands executed in order, using Gulp-execa.
As opposed to similar plugins or to child_process.exec()
, this uses execa
which provides:
- Better Windows support, including shebangs
- Faster and more secure commands, since no shell is used by default
- Execution of locally installed binaries
-
Interleaved
stdout
/stderr
gulp-execa
adds Gulp-specific features to execa
including:
- a task shortcut syntax
- configurable verbosity
- better errors
Commands can be executed either directly or inside a files stream. In streaming mode, unlike other libraries:
- commands are run in parallel, not serially
- output can be saved either in files or in variables
Example gulpfile.js
:
const { src, dest } = require('gulp')
const { task, exec, stream } = require('gulp-execa')
module.exports.audit = task('npm audit')
module.exports.outdated = async () => {
await exec('npm outdated')
}
module.exports.sort = () =>
src('*.txt')
.pipe(stream(({ path }) => `sort ${path}`))
.pipe(dest('sorted'))
The full documentation is available on GitHub.
Top comments (0)