8000 Fix: Normalize file paths in file operations for Windows compatibility by hd140283 · Pull Request #1044 · google/clasp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix: Normalize file paths in file operations for Windows compatibility #1044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2025

Conversation

hd140283
Copy link
Contributor

Fixes # (no related issue)

  • npm run test succeeds.
  • npm run lint succeeds.
  • Appropriate changes to README are included in PR. (N/A)

Summary

This PR fixes file path normalization in file operations to ensure compatibility with Windows environments.

Details

  • Corrected path normalization logic to handle Windows-specific file paths.
  • Updated test cases to verify correct path normalization on Windows.

Testing

All tests and lint checks were executed successfully on a Windows environment.

@sqrrrl sqrrrl merged commit edd619f into google:master Mar 26, 2025
2 checks passed
@hd140283 hd140283 deleted the fix/windows-path-issue branch March 27, 2025 07:47
@@ -197,7 +197,7 @@ export class Files {
const localPath = path.relative(process.cwd(), path.join(contentDir, filename));
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}));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the remote filepath format be dependent on the local OS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just moved normalizePath() to wrap the result of path.format(), since path.format() is OS-dependent.

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.

3 participants
0