Skip to content

Commit

Permalink
Add example for from
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 20, 2019
1 parent 2b1c3b8 commit 1e59fe5
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 @@ -23,4 +23,5 @@ They can also be run directly
- [`echo`](echo.gulpfile.js)
- [`verbose`](verbose.gulpfile.js)
- [`result`](result.gulpfile.js)
- [`from`](from.gulpfile.js)
- [`maxConcurrency`](max_concurrency.gulpfile.js)
26 changes: 26 additions & 0 deletions examples/from.gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Demo of the `from` option.
// This file can be directly run:
// - first install `gulp-execa` and `gulp`
// - then `bash node_modules/gulp-execa/examples/from.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, including `stderr`
.pipe(stream(({ path }) => `wc -l ${path}`, { from: 'all' }))
.pipe(
through.obj((file, encoding, func) => {
console.log(file.contents.toString())
func(null, file)
}),
)
12 changes: 12 additions & 0 deletions examples/from.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Demo of the `from` option.
# This file can be directly run:
# - first install `gulp-execa` and `gulp`
# - then `bash node_modules/gulp-execa/examples/from.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/from.gulpfile.js"

0 comments on commit 1e59fe5

Please sign in to comment.