2.0.1 • Published 3 years ago
@nooooooom/merge-dirs v2.0.1
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-devUsage
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.tsWe 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.tsThe 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.tsOptions
See options.ts.
Feature
Intuitive print statements on the shell, and provides path parsing capabilities.
License
MIT