Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cjroth/gulp-filelist
Output list of files in current stream to JSON file or custom format.
https://github.com/cjroth/gulp-filelist
angular angularjs gulp gulp-filelist javascript node node-js nodejs npm npm-module npm-package stream
Last synced: 5 days ago
JSON representation
Output list of files in current stream to JSON file or custom format.
- Host: GitHub
- URL: https://github.com/cjroth/gulp-filelist
- Owner: cjroth
- License: mit
- Created: 2014-09-01T08:21:06.000Z (about 10 years ago)
- Default Branch: main
- Last Pushed: 2023-03-22T05:28:16.000Z (over 1 year ago)
- Last Synced: 2024-09-19T16:08:27.071Z (about 2 months ago)
- Topics: angular, angularjs, gulp, gulp-filelist, javascript, node, node-js, nodejs, npm, npm-module, npm-package, stream
- Language: JavaScript
- Homepage:
- Size: 478 KB
- Stars: 15
- Watchers: 2
- Forks: 20
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-filelist
[![NPM Version](https://img.shields.io/npm/v/gulp-filelist.svg?style=flat)](https://www.npmjs.org/package/gulp-filelist)
[![NPM Downloads](https://img.shields.io/npm/dm/gulp-filelist.svg?style=flat)](https://www.npmjs.org/package/gulp-filelist)
[![Node.js Version](https://img.shields.io/badge/node.js->=_10-brightgreen.svg?style=flat)](http://nodejs.org/download/)
[![Build Status](https://travis-ci.com/cjroth/gulp-filelist.svg?branch=main)](https://travis-ci.org/cjroth/gulp-filelist)#### Output list of files in current stream to JSON file or custom format.
Add to your Node.js dev dependencies:
```bash
npm install --savedev gulp-filelist
```Add it to your gulp file:
```js
gulp
.src(['awesome.file', 'lame.file'])
.pipe(require('gulp-filelist')('filelist.json'))
.pipe(gulp.dest('out'))
```Outputs `out/filelist.json`:
```json
[
"awesome.file",
"lame.file"
]
```## Installation
```bash
$ npm install gulp-filelist
```## Options
#### Absolute Paths: `{ absolute: true }`
```
gulp
.src(['awesome.file', 'lame.file'])
.pipe(require('gulp-filelist')('filelist.json', { absolute: true }))
.pipe(gulp.dest('out'))
```
Outputs:
```
[
"/Users/chris/my-project/out/awesome.file",
"/Users/chris/my-project/out/lame.file"
]
```#### Relative Paths: `{ relative: true }`
```
gulp
.src(['awesome.file', 'lame.file'])
.pipe(require('gulp-rename')(function(path) { path.dirname = 'foo' }))
.pipe(require('gulp-filelist')('filelist.json', { relative: true }))
.pipe(gulp.dest('out'))
```
Outputs:
```
[
"foo/awesome.file",
"foo/lame.file"
]
```#### Flattened Paths: `{ flatten: true }`
```
gulp
.src(['awesome.file', 'lame.file'])
.pipe(require('gulp-filelist')('filelist.json', { flatten: true }))
.pipe(gulp.dest('out'))
```
Outputs:
```
[
"awesome.file",
"lame.file"
]
```#### Paths without Extensions: `{ removeExtensions: true }`
```
gulp
.src(['directory/awesome.file', 'directory/lame.file'])
.pipe(require('gulp-filelist')('filelist.json', { removeExtensions: true }))
.pipe(gulp.dest('out'))
```
Outputs:
```
[
"directory/awesome",
"directory/lame"
]
```#### Output file with custom template: `{ destRowTemplate: }`
usage with string template
```
gulp
.src(['directory/awesome.file', 'directory/lame.file'])
.pipe(require('gulp-filelist')('filelist.json', { destRowTemplate: "/// " }))
.pipe(gulp.dest('out'))
```
Outputs:
```
[
"/// ",
"/// "
]
```usage with formatter function
```
function formatter(filePath) {
return filePath.substring(filePath.lastIndexOf('/') + 1) + ': ' + filePath + '\r\n';
}gulp
.src(['directory/awesome.file', 'directory/lame.file'])
.pipe(require('gulp-filelist')('filelist.json', { destRowTemplate: formatter }))
.pipe(gulp.dest('out'))
```
Outputs:
```
[
"awesome: directory/awesome",
"lame: directory/lame"
]
```
## [MIT Licensed](LICENSE)