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

Overview

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

import { mergeDirs } from 'merge-dirs'

mergeDirs({
  // destination path of the merge operation
  dest: string

  /**
   * source paths to merge
   *
   * @example
   * ```ts
   * // 1. When a folder path is passed in,
   * // all files in the current folder will be merged to dest
   *
   * // dest: dest
   * // demo: src/demo/1.ts, src/demo/2.ts
   * mergeDirs({ dest: 'dest', path: ['src/demo'] })
   * // dest: dest/1.ts, dest/2.ts
   *
   * // 2. When a file path is passed in, the current file will be merged to dest
   *
   * // dest: dest
   * // demo: src/demo/1.ts
   * mergeDirs({ dest: 'dest', path: ['src/demo/1.ts'] })
   * // dest: dest/1.ts
   *
   * // 3. If you need to merge a single file under a folder and keep the folder path,
   * // you can use the options
   *
   * // dest: dest
   * // demo: src/demo/1.ts, src/demo/2.ts, src/demo2/2.ts
   * mergeDirs({ dest: 'dest', path: [{ rootDir: 'src', path: 'demo' }] })
   * // dest: dest/demo/1.ts, dest/demo/2.ts
   * ```
   */
  paths: (
    | string
    | {
        rootDir: string
        path: string
      }
  )[]

  /**
   * ignore errors when merging and continue with subsequent merges
   *
   * @default false
   */
  ignoreErrors?: boolean

  /**
   * ignore empty folders, if true, empty folders will not be merged into dest
   *
   * @default false
   */
  ignoreEmptyFolders?: boolean

  /**
   * How to resolve file conflicts, optional with:
   *
   * 'overwrite' | 'skip' | ((source: string, dest: string) => string)
   *
   * If you want to customize the conflict resolver,
   * please return the path where the files need to be merged eventually,
   * the valid values are source or dest or any filename in the same directory as dest
   *
   * @default 'overwrite'
   *
   * 'overwrite' | 'skip' | ((source: string, dest: string) => string)
   */
  conflictResolution?: ConflictResolution | ConflictResolver
})

Feature

Intuitive print statements on the shell, and provides path parsing capabilities.

License

MIT

You might also like...

This project scans yandex disk folders that are open to public sharing and allows you to download their contents.

This project scans yandex disk folders that are open to public sharing and allows you to download their contents.

kitapbar.com Development start mongodb server docker-compose -f docker-compose.dev.yaml up -d yandex service cd services/yandex create a .env file by

Oct 15, 2022

An npm package for demonstration purposes using TypeScript to build for both the ECMAScript Module format (i.e. ESM or ES Module) and CommonJS Module format. It can be used in Node.js and browser applications.

An npm package for demonstration purposes using TypeScript to build for both the ECMAScript Module format (i.e. ESM or ES Module) and CommonJS Module format. It can be used in Node.js and browser applications.

Dec 28, 2022

Create folder of snippets to activate them in one click !

Create folder of snippets to activate them in one click !

- FR Obsidian Group Snippet This plugin allow you to set group of CSS snippets to class them and enable them in one click (or command). Also, this pl

Dec 31, 2022

This is a simple script to upload Multiple files into google drive using google drive API and Nodejs.

Welcome to gDrive Multiple File Upload 👋 This is a simple script to upload Multiple files into google drive using google drive API and Nodejs Install

Dec 29, 2021

Bys is an npm/yarn library to merge your js and ts files into one file.

Bundle your scripts (bys) Bys is an npm/yarn library to merge your js and ts files into one file. Installation Use the npm or yarn package manager to

Dec 8, 2022

Yet another library for generating NFT artwork, uploading NFT assets and metadata to IPFS, deploying NFT smart contracts, and minting NFT collections

eznft Yet another library for generating NFT artwork, uploading NFT assets and metadata to IPFS, deploying NFT smart contracts, and minting NFT collec

Sep 21, 2022

Lightweight ( 2.3kB gzipped) and performant natural sorting of arrays and collections by differentiating between unicode characters, numbers, dates, etc.

fast-natural-order-by Lightweight ( 2.3kB gzipped) and performant natural sorting of arrays and collections by differentiating between unicode charac

Nov 14, 2022

Vite plugin to client bundle i18next locales composited from one to many json/yaml files from one to many libraries. Zero config HMR support included.

vite-plugin-i18next-loader yarn add -D vite-plugin-i18next-loader Vite plugin to client bundle i18next locales composited from one to many json/yaml f

Nov 30, 2022

ENS Collections are categories of ENS names based on specific patterns or predefined lists.

ENS Collections are categories of ENS names based on specific patterns or predefined lists. This repository is an effort towards standardizing their definition in order to increase consistency across platforms.

Dec 15, 2022
Owner
不见月
I'm just infected with a disease called curiosity
不见月
A script that combines a folder of SVG files into a single sprites file and generates type definitions for safe usage.

remix-sprites-example A script that combines a folder of .svg files into a single sprites.svg file and type definitions for safe usage. Technical Over

Nicolas Kleiderer 19 Nov 9, 2022
Automaticly parses known pocket ips patch resources, scans folders or zip files for matching roms and applies the patches.

Pocket Automaton Automaticly parses known pocket ips patch resources, scans folders or zip files for matching roms and applies the patches. Usage pock

null 3 Nov 27, 2022
File Hider - This is a plugin for Obsidian that allows hiding specific files and folders from the file explorer

File Hider - This is a plugin for Obsidian that allows hiding specific files and folders from the file explorer

Oliver 24 Dec 16, 2022
Organizes all your files from from a folder into different section automatically.

File System Organizer Global command line application Organizes all your files from from a folder into different section automatically. Functionality

KAJALIYA CHARCHIL 4 Jun 15, 2022
Recursively publish ESM packages as CommonJS!

Commonify.js For us who are still relying on CommonJS, or using Electron which does not support ESM. ?? See also build-electron I made this tool that

Mikael Finstad 31 Dec 29, 2022
NoExGen is a node.js express application generator with modern folder structure, namespace/project mapping and much more! It contains preconfigured Settings and Routing files, ready to be used in any project.

Installation $ npm install -g noexgen Quick Start You can use Node Package Execution to create your node-express application as shown below: Create th

Souvik Sen 7 Oct 8, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A DOM-merging algorithm

Idiomorph Idiomorph is a javascript library for morphing one DOM tree to another. It is inspired by other libraries that pioneered this functionality:

Big Sky Software 99 Dec 30, 2022