WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@AhsanCommits
Copy link

Fixes #1280

Summary

Normalizes path separators to forward slashes in test output for cross-platform compatibility.

Changes

  • Modified buckets.ts to normalize backslashes to forward slashes in returned paths
  • Modified find-locale-paths.ts to normalize path separators in patterns
  • Added changeset

Testing

All 554 tests pass on Windows 11 (Node v22.19.0, pnpm 9.12.3):

  • ✓ buckets.spec.ts (4 tests)
  • ✓ find-locale-paths.spec.ts (8 tests)
  • ✓ Full test suite (554 tests)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes CLI tests failing on Windows by normalizing path separators from backslashes to forward slashes for cross-platform compatibility.

  • Normalizes path separators in buckets.ts to return forward slashes in placeholdered paths
  • Normalizes path separators in find-locale-paths.ts patterns
  • Adds changeset documenting the fix

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/cli/src/cli/utils/buckets.ts Converts backslashes to forward slashes in returned placeholdered paths
packages/cli/src/cli/utils/find-locale-paths.ts Normalizes path separators in pattern strings
.changeset/fix-windows-path-separators.md Documents the fix as a patch release
Comments suppressed due to low confidence (1)

packages/cli/src/cli/utils/buckets.ts:154

  • Converting forward slashes to path.sep at line 153, then later converting back to forward slashes at line 179 creates unnecessary back-and-forth conversions. This approach conflicts with the stated goal of normalizing to forward slashes throughout. Consider keeping forward slashes consistently or refactoring the path handling logic.
    const normalizedSourcePath = normalizePath(
      sourcePath.replace(/\//g, path.sep),
    );

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 175 to +179
const placeholderedPath = sourcePathChunks.join(path.sep);
return placeholderedPath;
});
// return the placeholdered paths
return placeholderedPaths;
// return the placeholdered paths (normalized to forward slashes for cross-platform compatibility)
return placeholderedPaths.map(p => p.replace(/\\/g, "/"));
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

The normalization is performed after constructing paths with path.sep, which creates platform-specific separators only to immediately replace them. Consider normalizing earlier at line 175 by using sourcePathChunks.join('/') directly instead of path.sep, which would be more efficient and avoid the redundant mapping step.

Copilot uses AI. Check for mistakes.
// return the placeholdered paths
return placeholderedPaths;
// return the placeholdered paths (normalized to forward slashes for cross-platform compatibility)
return placeholderedPaths.map(p => p.replace(/\\/g, "/"));
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

[nitpick] Arrow function parameter lacks proper spacing around the arrow. Should be p => p.replace (with space before arrow) for consistency with project style. This is already done correctly in the codebase elsewhere.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI tests fail on Windows due to path separator differences

2 participants