UNPKG

gulp-choose-files

Version:

Gulp plugin that prompts you to choose the files to pass through the stream.

116 lines (76 loc) 3.92 kB
# gulp-choose-files [![NPM version](https://img.shields.io/npm/v/gulp-choose-files.svg?style=flat)](https://www.npmjs.com/package/gulp-choose-files) [![NPM monthly downloads](https://img.shields.io/npm/dm/gulp-choose-files.svg?style=flat)](https://npmjs.org/package/gulp-choose-files) [![NPM total downloads](https://img.shields.io/npm/dt/gulp-choose-files.svg?style=flat)](https://npmjs.org/package/gulp-choose-files) > Gulp plugin that prompts you to choose the files to pass through the stream. ## Install Install with [npm](https://www.npmjs.com/): ```sh $ npm install --save gulp-choose-files ``` Install with [yarn](https://yarnpkg.com): ```sh $ yarn add gulp-choose-files ``` ![gulp choose files example](example.gif) ## Usage ```js var gulp = require('gulp'); var choose = require('gulp-choose-files'); gulp.task('default', function() { return gulp.src('fixtures/*.*') .pipe(choose()) .pipe(gulp.dest('actual')); }); ``` ## options.key **Type**: `string` **Default**: `relative` Specify the [vinyl](https://github.com/gulpjs/vinyl) `file` property to use when displaying file names in the choices array. **Examples** Given the file path `/dev/fixtures/foo.txt` (depending on cwd and `file.base`), here is what you would get: ```js choose({key: 'path'}); //=> '/dev/fixtures/foo.txt' choose({key: 'relative'}); //=> 'fixtures/foo.txt' choose({key: 'basename'}); //=> 'foo.txt' choose({key: 'stem'}); //=> 'foo' ``` ## options.choices If you need to be able to automatically skip the prompt, you can pass a string or array with your "choices" to `options.choices`. The following will only write `a.txt`: ```js gulp.task('default', function() { return gulp.src('fixtures/*.txt') .pipe(choose({choices: ['a.txt']})) .pipe(gulp.dest('actual')); }); ``` ## About ### Related projects * [gulp-choose-file](https://www.npmjs.com/package/gulp-choose-file): Gulp plugin that prompts you to choose a file to pass through the stream. | [homepage](https://github.com/pointnet/gulp-choose-file "Gulp plugin that prompts you to choose a file to pass through the stream.") * [gulp-condense](https://www.npmjs.com/package/gulp-condense): Remove extra newlines in a string. | [homepage](https://github.com/jonschlinkert/gulp-condense "Remove extra newlines in a string.") * [gulp-extname](https://www.npmjs.com/package/gulp-extname): gulp plugin to dynamically rewrite dest extensions based on src extensions. | [homepage](https://github.com/jonschlinkert/gulp-extname "gulp plugin to dynamically rewrite dest extensions based on src extensions.") * [gulp-htmlmin](https://www.npmjs.com/package/gulp-htmlmin): gulp plugin to minify HTML. | [homepage](https://github.com/jonschlinkert/gulp-htmlmin#readme "gulp plugin to minify HTML.") ### Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). ### Building docs _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ To generate the readme, run the following command: ```sh $ npm install -g verbose/verb#dev verb-generate-readme && verb ``` ### Running tests Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: ```sh $ npm install && npm test ``` ### Author **Jon Schlinkert** * [github/jonschlinkert](https://github.com/jonschlinkert) * [twitter/jonschlinkert](https://twitter.com/jonschlinkert) ### License Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). Released under the [MIT License](LICENSE). *** _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on April 28, 2017._