
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@taskr/flatten
Advanced tools
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.
$ npm install --save-dev @taskr/flatten
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
Type: Number
Default: 0
The number of sub-directories allowed in relation to your glob root.
All examples use the demo file tree listed above.
No parent directories are kept.
Note: The
imgdirectory is kept because we've used.target('dist/img').
dist
├── img
│ ├── img.jpg
│ ├── foo.jpg
│ ├── bar.jpg
Each file is allowed to keep 1 parent directory.
dist
├── img
│ ├── img.jpg
│ ├── foo
│ ├── foo.jpg
│ ├── bar
│ ├── bar.jpg
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
Any issues or questions can be sent to the Taskr monorepo.
Please be sure to specify that you are using @taskr/flatten.
MIT © Luke Edwards
FAQs
Flatten all source files to a specified maximum of sub-directories.
We found that @taskr/flatten demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.