DEV Community

loading...

Gulp.js command execution for humans.

ehmicky
・2 min read

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'))

The full documentation is available on GitHub.

Discussion (0)