Fix: Normalize file paths in file operations for Windows compatibility#1044
Merged
Conversation
Nu11u5
reviewed
Apr 22, 2025
| const resolvedPath = path.relative(contentDir, localPath); | ||
| const parsedPath = path.parse(resolvedPath); | ||
| let remotePath = path.format({dir: normalizePath(parsedPath.dir), name: parsedPath.name}); | ||
| let remotePath = normalizePath(path.format({dir: parsedPath.dir, name: parsedPath.name})); |
Contributor
There was a problem hiding this comment.
Should the remote filepath format be dependent on the local OS?
Contributor
Author
There was a problem hiding this comment.
Just to clarify:
The remote path is normalized using normalize-path, so it's always converted to POSIX format (/), regardless of the local OS. This ensures consistent behavior across different environments.
That logic was implemented in my PR and has already been merged into the master branch — but it hasn’t been released to NPM yet.
If you're using the latest published version of @google/clasp, the change may not be included yet.
Contributor
Author
There was a problem hiding this comment.
I just moved normalizePath() to wrap the result of path.format(), since path.format() is OS-dependent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes # (no related issue)
npm run testsucceeds.npm run lintsucceeds.Summary
This PR fixes file path normalization in file operations to ensure compatibility with Windows environments.
Details
Testing
All tests and lint checks were executed successfully on a Windows environment.