sindresorhus / cpy-cli

Copy files
MIT License
345 stars 33 forks source link

file already exists #17

Open dy opened 5 years ago

dy commented 5 years ago

We have .env and .env.development files in the C:\projects\xxx\. Running cpy gives:

$ npx cpy './.env.development' './.env'
Cannot copy from `C:\projects\xxx\.env.development` to `C:\projects\xxx\.env\.env.development`: Cannot create directory `C:\projects\xxx\.env`: EEXIST: file already exists, mkdir 'C:\projects\xxx\.env'

Is that the expected result? Is there a workaround? @sindresorhus

revelt commented 5 years ago

Wait, but you said .env is a file, then why is it put as a destination, ./.env, the second argument above?

To me it looks like you're putting two source files and incorrectly assuming second will be a destination.

If you really had two dot files, you could use globs. For example, if both files are in current directory, then try:

npx cpy ".*" "c:\projects\secret_folder"

or do one-by-one...

Please update how it went. And please correct me if I misunderstood the question. Cheers

dy commented 5 years ago

@revelt I just expected the way cp works, so I used shx for that:

shx cp ./.env.development ./.env

Not sure what trouple cpy makes of files named .env.sfx

revelt commented 5 years ago

I see... Do you think we can solve this or are you happy with shx? I'm a user of this cli myself and one-to-one file copying works fine. But API can always be improved, it's just we have to draw up a persuasive case first. What do you think @dy ?

dy commented 5 years ago

That seems to be an issue of related cpy and other packages. Needs resolution. I'd rather set a tip to @sindresorhus for fixing that case, that'd be faster. So far I'm fine with shx

sindresorhus commented 5 years ago

Yeah, that's a bug in cpy. It should allow the the destination to be a file if the source is just one file and the destination doesn't already exist as a directory.

dsumac commented 1 year ago

Hello Is there any news about this issue ?