Skip to content

Fix relative path handling and path normalization#120

Merged
sindresorhus merged 4 commits intosindresorhus:mainfrom
sigJoe:fixes
Aug 20, 2025
Merged

Fix relative path handling and path normalization#120
sindresorhus merged 4 commits intosindresorhus:mainfrom
sigJoe:fixes

Conversation

@sigJoe
Copy link
Contributor

@sigJoe sigJoe commented Aug 18, 2025

Two issues:

  • Copying files outside the cwd didn't put files in the destination
  • While writing tests for the above, I noticed it broke on paths like ././././file.txt so I added path normalization

To reproduce:

mkdir test
cd test
mkdir -p code dest src/a/b
touch src/a/b/foo.txt
cd code
npm i cpy-cli@6.0.0
npx cpy '../src/a/b/foo.txt' '../dest'
cd ..
find . -path "*/node_modules" -prune -o -print

# Before fix
.
./code
./code/package-lock.json
./code/package.json
./dest <- empty dest :(
./src
./src/a
./src/a/b
./src/a/b/foo.txt

# After fix
.
./code
./code/package-lock.json
./code/package.json
./dest
./dest/foo.txt <- exactly where I want it
./src
./src/a
./src/a/b
./src/a/b/foo.txt

@sigJoe
Copy link
Contributor Author

sigJoe commented Aug 18, 2025

Ugh Windows

@sigJoe
Copy link
Contributor Author

sigJoe commented Aug 18, 2025

Went so far as to set up a Windows Server 2025 VM, but all the unit tests pass perfectly fine. This is somehow a Github issue (?)

@sindresorhus sindresorhus merged commit c20ee96 into sindresorhus:main Aug 20, 2025
18 of 27 checks passed
@sindresorhus
Copy link
Owner

Thanks :)

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

Successfully merging this pull request may close these issues.

2 participants