From 1e59fe54f0c8d562c56104f665f00573d63d584b Mon Sep 17 00:00:00 2001 From: ehmicky Date: Mon, 20 May 2019 10:00:00 +0200 Subject: [PATCH] Add example for from --- examples/README.md | 1 + examples/from.gulpfile.js | 26 ++++++++++++++++++++++++++ examples/from.sh | 12 ++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 examples/from.gulpfile.js create mode 100755 examples/from.sh diff --git a/examples/README.md b/examples/README.md index 73a110e..2b2730b 100644 --- a/examples/README.md +++ b/examples/README.md @@ -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) diff --git a/examples/from.gulpfile.js b/examples/from.gulpfile.js new file mode 100644 index 0000000..b9a4a80 --- /dev/null +++ b/examples/from.gulpfile.js @@ -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) + }), + ) diff --git a/examples/from.sh b/examples/from.sh new file mode 100755 index 0000000..2a2d6ad --- /dev/null +++ b/examples/from.sh @@ -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"