@flemist/copy-glob-flat
v0.0.5
Published
Copy files to single directory with auto rename duplicates
Downloads
9
Maintainers
Readme
Copy files to single directory with auto rename duplicates
Installation
npm i @flemist/copy-glob-flat
Usage CLI
cp-flat <SOURCE_GLOB1> <SOURCE_GLOB2> ... <DEST_DIR>
cp-flat src/**/*.txt !**/ignore.txt tmp/destDir
Usage module
import {copyGlobFlat} from '@flemist/copy-glob-flat'
/*
Initial:
/source
/dir
/dir1
file.txt
ignore.txt
/dir2
file.txt
ignore.txt
file.txt
ignore.txt
file.txt
ignore.txt
/dest
/file2.txt
file.txt
file1.txt
*/
await copyGlobFlat({
destDir: 'tmp',
globs: [
'**/*.txt',
'**/!ignore.txt',
],
})
/*
Result:
/source
...
/dest
/file2.txt
file.txt
file.txt - copied from source/file
file0.txt - copied from source/dir/file
file1.txt
file3.txt - copied from source/dir/dir1/file
file4.txt - copied from source/dir/dir2/file
*/