sindresorhus / cpy-cli

Copy files
MIT License
344 stars 33 forks source link

`--cwd` flag does not work #35

Open ZebraFlesh opened 2 years ago

ZebraFlesh commented 2 years ago

Previously I was executing the following command with 3.1.x

cpy **/*.scss !**/*.stories.scss ../lib --parents --cwd=src

with a result similar to:

% ls lib/**/*.scss 
lib/Button/Button.scss
lib/ButtonLink/ButtonLink.scss
lib/Checkbox/Checkbox.scss

However, the 4.0 release doesn't find any files to copy. This seems like a globbing problem.

sindresorhus commented 2 years ago

Does it work if you remove !**/*.stories.scss?

sindresorhus commented 2 years ago

// @andy2mrqz

ZebraFlesh commented 2 years ago

Does it work if you remove !**/*.stories.scss?

Strangely no: it encounters an error trying to copy a file from the node_modules directory, which is a sibling to src. So it seems like the --cwd=src flag is not being honored. (If the flag was honored, cpy-cli wouldn't even traverse into the node_modules directory.)

farfromrefug commented 2 years ago

I face the same issue. 4.x is not working for me anymore. Had to rollback to 3.x

andy2mrqz commented 2 years ago

@sindresorhus thanks for tagging, I totally missed the notifications and didn't see this until now.

I inspected #34 to see if that could have introduced a regression. The areas that my PR touched were:

I think the regression may have been introduced in cpy v9, which this package proxies to, in sindresorhus/cpy#92. The most recent comment as of writing mentions an issue very similar to this one.

I also was able to recreate this issue by creating a simple repo with cpy and the file structure that ZebraFresh mentioned in his description. This seems to indicate that cpy-cli is not the failure point.

Sometime in the coming days/weeks I'll spend some time and see if I can resolve the issue in cpy - but the main blockers there are time and my lack of familiarity with cpy internals. Anyone else interested should feel free to jump in and contribute as well, if able.

jurijzahn8019 commented 2 years ago

Hi there,

The current behavior i see is, that glob patterns must start with a posix path segment:

**/* will not work.

Possible fix could be

farfromrefug commented 1 year ago

Just managed to fix this in my setup and i saw actually 1 issue and 1 breaking change:

RiZKiT commented 12 months ago

Not sure if it is related or if I should open another ticket, but with 5.0.0 --cwd isn't working for us anymore the way it does in 4.x, so we had to switch back to 4.x.

stweet commented 7 months ago

with 5.0.0 don't work '--cwd'

farfromrefug commented 7 months ago

@sindresorhus would be nice to have some feedback on this. I have been stuck on 3.x because of this. Hope you can look at it