Socket
Book a DemoInstallSign in
Socket

@taskr/flatten

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@taskr/flatten

Flatten all source files to a specified maximum of sub-directories.

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

@taskr/flatten npm

Flatten all source files to a specified maximum of sub-directories.

A source's directory structure isn't always desirable in the output. With @taskr/flatten, you may dictate how many parent directories of a file to keep.

Install

$ npm install --save-dev @taskr/flatten

Usage

src
├── images
│   ├── img.jpg
│   ├── foo
│      ├── foo.jpg
│      ├── bar
│         ├── bar.jpg
exports.images = function * (task) {
  yield task.source('src/images/**/*.jpg').flatten({ levels: 1 }).target('dist/img');
}
# output
dist
├── img
│   ├── img.jpg
│   ├── foo
│      ├── foo.jpg
│   ├── bar
│      ├── bar.jpg

API

.flatten(options)

options.levels

Type: Number
Default: 0

The number of sub-directories allowed in relation to your glob root.

Examples

All examples use the demo file tree listed above.

Level: 0

No parent directories are kept.

Note: The img directory is kept because we've used .target('dist/img').

dist
├── img
│   ├── img.jpg
│   ├── foo.jpg
│   ├── bar.jpg

Level: 1

Each file is allowed to keep 1 parent directory.

dist
├── img
│   ├── img.jpg
│   ├── foo
│      ├── foo.jpg
│   ├── bar
│      ├── bar.jpg

Level: 5

Our file tree is only 2 levels deep (images [0]/foo [1]/bar [2]/bar.jpg). Because our "allowed levels" exceeds our tree depth, @taskr/flatten won't do anthing and so the entire structure will be copied.

dist
├── img
│   ├── img.jpg
│   ├── foo
│      ├── foo.jpg
│      ├── bar
│         ├── bar.jpg

Support

Any issues or questions can be sent to the Taskr monorepo.

Please be sure to specify that you are using @taskr/flatten.

License

MIT © Luke Edwards

Keywords

taskr

FAQs

Package last updated on 27 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts