sindresorhus / cpy-cli

Copy files
MIT License
345 stars 33 forks source link

Help converting syntax for package.json script #39

Closed gregpettit closed 2 years ago

gregpettit commented 2 years ago

I am using this for a build process that is simple enough to live strictly in NPM via scripts in package.json.

I have no problems using the tool when the syntax uses wildcards in directory; for example:

cpy ../../../shared/picker/*.min.js dist/js/vendor/

But it doesn't do anything (nor throw an actual error, mind you) when I try to single out just a specific file like this:

cpy ../../../shared/picker/picker.min.js dist/js/vendor/

I tried understanding how to translate the original API from "cpy", but the samples were Javascript function calls rather than passing arguments in the command line.

Is the single-file method not supported, or am I missing something in my syntax?

gregpettit commented 2 years ago

I just noticed that at the level of the package.json script, I have shared/picker/picker.min.js

seems to want to maintain everything starting at and including "shared" as a directory structure, and not navigate into dist/js/vendor in the destination. Clearly the single file copy IS supported, and I'm just a numpty who can't figure out the syntax. Any help would be greatly appreciated, but I recognize that this is a PEBCAK.

gregpettit commented 2 years ago

The solution was just using the --flat option:

cpy ../../../shared/picker/picker.min.js dist/js/vendor/ --flat