2.0.1 • Published 1 year ago

@nooooooom/merge-dirs v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

2.0.1

1 year ago

2.0.0

1 year ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago