@nooooooom/merge-dirs
v2.0.1
Published
Node module for synchronously and recursively merging multiple folders or collections of files into one folder.
Downloads
122
Maintainers
Readme
merge-dirs
Node module for synchronously and recursively merging multiple folders or collections of files into one folder.
Install
yarn add @nooooooom/merge-dirs --dev
# or
pnpm install @nooooooom/merge-dirs --save-dev
Usage
merge-dirs
is based on the parsing mode of fast-glob
, which will merge all matched paths into dest.
Consider the directory structure:
|- dest
|- bar
|- a.ts
|- foo
|- b.ts
|- bar
|- c.ts
We need to merge foo
and all files in bar
into dest
:
await mergeDirs({
targets: [
{
dest: 'dest',
src: ['source/foo/*']
}
]
})
it will become:
|- dest
|- bar
|- a.ts
|- c.ts
|- b.ts
|- foo
|- b.ts
|- bar
|- c.ts
The expectation of merge-dirs
is to merge all files and folders recursively, but sometimes you may need to overwrite the entire folder instead of merging the files under the folder, you can use target.overwriteDirectory
:
await mergeDirs({
targets: [
{
dest: 'dest',
src: ['source/foo/*'],
overwriteDirectory: true
}
]
})
it will become:
|- dest
|- bar
|- c.ts
|- b.ts
|- foo
|- b.ts
|- bar
|- c.ts
Options
See options.ts.
Feature
Intuitive print statements on the shell, and provides path parsing capabilities.
License
MIT