Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] not working in npm script if use ' #30

Open
rendomnet opened this issue Apr 19, 2021 · 5 comments
Open

[Windows] not working in npm script if use ' #30

rendomnet opened this issue Apr 19, 2021 · 5 comments

Comments

@rendomnet
Copy link

rendomnet commented Apr 19, 2021

If I use npm script
"copy": "cpy './package.json' dist"

npm run copy
it will give me error
Cannot copy './package.json': the file doesn't exist

But if I remove ' like this cpy ./package.json dist it will run correctly

Windows 10
Node 10.24.1

@whizkidwwe1217
Copy link

@rendomnet You can escape a double quote "copy": "cpy \"./package.json\" dist"

@jhildenbiddle
Copy link

FYI --

Removing the single quotes surrounding the paths resolved the issue for me.

Using the example from the OP:

"copy": "cpy ./package.json dist"

@BePo65
Copy link

BePo65 commented Dec 27, 2021

I had the same problem. I think this is a documentation thing, as the README e.g. in npmjs says

: 
Examples
    Copy all .png files in src folder into dist except src/goat.png
    $ cpy 'src/*.png' '!src/goat.png' dist     <-- here we have single quotes that cause the problems

    Copy all .html files inside src folder into dist and preserve path structure
    $ cpy '**/*.html' '../dist/' --cwd=src --parents     <-- here we have single quotes that cause the problems
: 

but as @jhildenbiddle wrote, the single quotes are unnecessary (if the paths don't contain spaces - in that case escaping double quotes around the paths will solve the problem as @whizkidwwe1217 wrote)

So: wouldn't it be a good idea to update the README?

@ediblecode
Copy link

FWIW, I had a process running locally on Windows and on a TeamCity build agent on linux. Removing single quotes made it work OK on Windows but not on linux, Whereas using escaped double quotes as per @whizkidwwe1217's answer worked on both platforms.

@seanohue
Copy link

I ran into a similar problem on Mac as well when using cpy-cli 5.0.0 -- after upgrading from an earlier version I found my copy command broke -- files were no longer being copied in a recursive manner. After removing single quotes that I had wrapping all of the "source" parameters, it worked as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants