kpy
CLI and Node.js API to copy files with globs, promises, typescript and stuff.
Features
- Dead simple (see examples), minimalistic
- Provides both CLI and API (so you don't need 2 separate packages)
- Provides Typescript typings (so you don't need 3 separate packages)
- Relies on proven lower-level libs (globby, cp-file, yargs)
- Report progress to STDOUT by default (unless
--silent
is used)
Just run kpy help
to see CLI options.
CLI API
kpy <baseDir> <pattern1> <pattern2> ... <outputDir>
kpy test out
kpy test '**/*.txt' '!**/one.txt' out
Options:
--silent
- don't output anything--verbose
- report progress on every file--dotfiles
- include files starting with .
--no-overwrite
- don't overwrite--flat
- flatten the output folders--dry
- don't copy (useful for debugging)--move
- move files instead of copyhelp
- show available options
Why
cpy
has issue with --cwd
, --parents
. --parents
should be default, and cwd
is confusing.
cpx
is amazing, but doesn't support multiple globs and therefore negation globs (e.g
test/* !test/one.txt
)
Example 1
Copy all files/dirs while keeping directory structure from test/*
to out
.
Simple, right?
cpy
cpy ** ../out --cwd test --parent
Possible, but not trivial to figure out ..out
, --cwd
, etc.
cpx
cpx out test
Works really well here!
Example 2
Copy all files/dirs while keeping directory structure from test/*.txt
to out
, excluding
one.txt
.
Simple, right?
cpy
cpy ** !**/one.txt ../out --cwd test --parent
Possible, but not trivial to figure out ..out
, --cwd
, etc.
cpx
Not possible to exclude :(
del
This package also provides del
cli (api similar and inspired by
del.
Examples:
del dist
del 'dist/**'
del 'dist/**/*.json'
del dist '!**/*.json'
del a b c