@hutsoninc/flatten-dir

1.0.3 • Public • Published

flatten-dir

Build Status Current npm package version

Recursively flatten a directory (moves all files from subfolders into the one folder).

Usage

npm install @hutsoninc/flatten-dir

const flatten = require('@hutsoninc/flatten-dir');

await flatten('path-to-directory', {
    // options
});

Options

rename

Type: Function

Used to rename a file when the file name is already taken.

Default:

basename => {
    if (/-\d$/.test(basename)) {
        let arr = basename.split('-');
        arr[arr.length - 1] = Number(arr[arr.length - 1]) + 1;
        return arr.join('-');
    }
    return `${basename}-1`;
}

Related

License

MIT © Hutson Inc

Readme

Keywords

none

Package Sidebar

Install

npm i @hutsoninc/flatten-dir

Weekly Downloads

149

Version

1.0.3

License

MIT

Unpacked Size

5.97 kB

Total Files

6

Last publish

Collaborators

  • austinleegordon