shx icon indicating copy to clipboard operation
shx copied to clipboard

Moving with glob pattern fails on Windows but works fine on Linux

Open t00 opened this issue 1 year ago • 3 comments

I have a part of a script which copies playwright tests artifacts from a temporary folder to a permanent one. The purpose is to copy all subdirectories from the test-results/ directory to the results/ directory.

shx mv test-results/** results/

When running on Linux it does not output anything and copies directories as expected.

On Windows it throws the following error:

mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-1.png
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-10.png
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-11.png
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-12.png
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-13.png
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-14.png
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-15.png
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-16.png
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-2.png
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-3.png
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-4.png
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-5.png
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-6.png
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-7.png
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-8.png
mv: no such file or directory: test-results/playwright-8247-monitor-co-76a6b-or---Connections-tab-8247-1-Chrome-Stable/test-failed-9.png
ERROR: "playwright:run2:8247" exited with 1.

I am using forward slashes on both but possibly on Windows these are not handled the same way?

t00 avatar Dec 16 '24 08:12 t00

I just changed the command to shx cp -r test-results/* results/ and the contents are copied correctly. This suggests some globbing pattern emulation differences on Windows.

t00 avatar Dec 16 '24 09:12 t00

Why not just try shx cp -r test-results/ results/? You should run this before the results folder is created. This command will then create results/ and all of its sub directories will match the subdirectories of test-results/.

No need for glob expressions and it's a lot simpler. Let me know if I've misunderstood your goal.

nfischer avatar Dec 20 '24 22:12 nfischer

Regarding glob expressions, please read https://github.com/shelljs/shx#packagejson (the globbing guidance applies whether it's in package.json or not—I should refactor that guidance into a new section of the documentation).

nfischer avatar Dec 20 '24 22:12 nfischer