@nooooooom/merge-dirs
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

merge-dirs

Node module for synchronously and recursively merging multiple folders or collections of files into one folder.

npm version

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

Package Sidebar

Install

npm i @nooooooom/merge-dirs

Weekly Downloads

7

Version

2.0.1

License

MIT

Unpacked Size

73.6 kB

Total Files

10

Last publish

Collaborators

  • nooooooom