Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/martypdx/gobble-flatten
Gobble transform that flattens all files into top-level directory
https://github.com/martypdx/gobble-flatten
Last synced: about 10 hours ago
JSON representation
Gobble transform that flattens all files into top-level directory
- Host: GitHub
- URL: https://github.com/martypdx/gobble-flatten
- Owner: martypdx
- Created: 2015-12-15T15:27:42.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-05-22T17:46:39.000Z (over 8 years ago)
- Last Synced: 2024-10-12T14:50:01.642Z (about 1 month ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gobble-flatten
Simple gobble transformation that flattens all files in folders and subfolders with gobble
## Installation
First, you need to have gobble installed - see the [gobble readme](https://github.com/gobblejs/gobble) for details. Then,
```bash
npm i -D gobble-flatten
```## Usage
**gobblefile.js**
```js
var gobble = require( 'gobble' );
module.exports = gobble( 'someFolder' ).transform( 'flatten' );
```Transforms:
```
|- file1.js
|- file2.js
|- folder1
|- file3.js
|- file4.js
|- folder2
|- file5.js
|- folder3
```Into:
```
|- file1.js
|- file2.js
|- file3.js
|- file4.js
|- file5.js
```Use gobble's built in [`include`](https://github.com/gobblejs/gobble/wiki/API-reference#nodeinclude-patterns-) and [`exlcude`](https://github.com/gobblejs/gobble/wiki/API-reference#nodeexclude-patterns-) to filter results:
```
gobble( 'someFolder' ).include( '**/*.html' ).transform( 'flatten' );
```Duplicate file names currently handled on a last-wins basis.
## Tests
Uses [gobble-test](https://github.com/gobblejs/gobble-test) example based testing. Run via:
```bash
npm test
```## Credits
Uses [sander](https://github.com/rich-harris/sander) for recursive directory listing and promised-based file system access.
## License
[MIT](https://opensource.org/licenses/MIT). Copyright 2016 Marty Nelson