DEV Community

ehmicky
ehmicky

Posted on

Gulp.js command execution for humans.

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:

gulp-execa adds Gulp-specific features to execa including:

Commands can be executed either directly or inside a files stream. In streaming mode, unlike other libraries:

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'))
Enter fullscreen mode Exit fullscreen mode

The full documentation is available on GitHub.

Top comments (0)