sindresorhus/cpy-cli

Cannot simply copy an entire folder

Opened this issue · 16 comments

MoOx commented

Issuehunt badges

I am getting errors for all folder with this command

cpy test/dist somewhere
Cannot glob `test/dist/folder, test/dist/folder-2`:  EISDIR: illegal operation on a directory, read

I tried

cpy test/dist/**/* somewhere

but same result.

I understand why there is an error, but it's pretty weird to not be able to ignore folder, I would have make this the default behavior.


IssueHunt Summary

Backers (Total: $80.00)

Submitted pull Requests


Become a backer now!

Or submit a pull request to get the deposits!

Tips

I've tried the following based on the discussion, that you've linked:

cpy --recursive static public
cpy --recursive static/* public
cpy --recursive static/**/* public
cpy --recursive 'static' 'public'

In every case I've got an error saying: `files` and `destination` required

Tried adding the --recursive after the folders and I've got the same EISDIR error, that MoOx mentioned.

Getting a similar problem. Can't get --recursive to work either.

Context: Using nps with cpy-cli as a dependency of nps-utils. Project is running on Windows.

kevva commented

There's no recursive option, it's just a suggestion in that issue. I think sindresorhus/globby#46 will help this issue move forward.

@kevva Yup, found that out eventually. Since I'm calling cpy-cli through nps-utils, I'm moving to nps-utils repository instead to try and find a more direct workaround (use ncp or fs-extra instead of cpy-cli).

same here,

cpy somepath/**/*.* somewhere works for me.

cpy somepath/**/. somewhere works for me.

...except the **/*.* file glob selects only filenames with extension, which excludes files like LICENSE, README, etc.
When switching to the **/* glob syntax, the error EISDIR: illegal operation on a directory is raised because the last * matches folder names. Any tips?

Ah, so this is already discussed here:
sindresorhus/cpy#40
and:
sindresorhus/cpy#10

...and I see that there is a pending Pull Request to leverage the existing nodir option:
#5

Did anyone ever found the solution to this?

I need to make cpy-cli copy files (manifest.json) & folder (icons/) cross-platform into dist/. Currently, it only copies files.

I tried this

"scripts": {
    "postbuild": "cpy --recursive 'manifest.json' 'icons/**' 'dist'"
}

But it copies contents of icons/ like so

  • dist
    • icon1.png

But I want to copy the whole folder into dist/ like so

  • dist
    • icons/
      • icon1.png

Any solutions?

@IssueHunt has funded $80.00 to this issue.


Rowno commented

@sindresorhus How would you feel about adding an --up flag like the copyfiles package has? This could then be combined with the --parents flag. If it sounds good to you I might implement it.

@Rowno Sure, if that resolves all the issues mentioned in this thread.

@sindresorhus How would you feel about adding an --up flag like the copyfiles package has? This could then be combined with the --parents flag. If it sounds good to you I might implement it.

I have started working on fixing this issue by using the previous solution. Let me know if you have any additional tips.