Skip to content

Commit

Permalink
Add example for result
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 20, 2019
1 parent 97fa6aa commit ae3ecdc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ They can also be run directly

- [`echo`](echo.gulpfile.js)
- [`verbose`](verbose.gulpfile.js)
- [`result`](result.gulpfile.js)
- [`maxConcurrency`](max_concurrency.gulpfile.js)
26 changes: 26 additions & 0 deletions examples/result.gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Demo of the `result` option.
// This file can be directly run:
// - first install `gulp-execa` and `gulp`
// - then `bash node_modules/gulp-execa/examples/result.sh`
// An online demo is also available at:
// https://repl.it/@ehmicky/gulp-execa

'use strict'

// Ignore the following line: this is only needed for internal purposes.
require('./utils.js')

const { src } = require('gulp')
const { stream } = require('gulp-execa')
const through = require('through2')

module.exports.default = () =>
src('**/*')
// Prints the number of lines of each file
.pipe(stream(({ path }) => `wc -l ${path}`, { result: 'save' }))
.pipe(
through.obj((file, encoding, func) => {
console.log(file.execa[0].stdout)
func(null, file)
}),
)
12 changes: 12 additions & 0 deletions examples/result.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Demo of the `result` option.
# This file can be directly run:
# - first install `gulp-execa` and `gulp`
# - then `bash node_modules/gulp-execa/examples/result.sh`
# An online demo is also available at:
# https://repl.it/@ehmicky/gulp-execa

# Ignore the following line: this is only needed for internal purposes.
. "$(dirname "$BASH_SOURCE")/utils.sh"

gulp --gulpfile="$dir/result.gulpfile.js"

0 comments on commit ae3ecdc

Please sign in to comment.