Skip to content

fix(cli): correct broken handling of Windows paths in inline command #18488

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 6 commits into from
Apr 10, 2025

Conversation

nchevsky
Copy link
Contributor

@nchevsky nchevsky commented Jan 30, 2025

Fixes #16963 (closed with no resolution after the author disappeared).

Corrects broken handling of Windows paths in the inline command—used by the @carbon/grid build—by passing option glob.windowsPathsNoEscape to replace-in-file.

💡 This is the first in a series of patches to enable building all of Carbon on Windows natively, without WSL. 🚀

Testing / Reviewing

Build @carbon/grid on a native Windows environment, or take my word for it:

Before ❌ After ✅
image image

Copy link
Contributor

github-actions bot commented Jan 30, 2025

All contributors have signed the DCO.
Posted by the DCO Assistant Lite bot.

@nchevsky

This comment was marked as resolved.

Copy link

netlify bot commented Jan 30, 2025

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit 8351b46
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/67f786e77391b30008c5e832
😎 Deploy Preview https://deploy-preview-18488--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines 124 to 130
await replace({
files: file.path,
from: REPLACE_REGEX,
glob: { windowsPathsNoEscape: true },
to(_, match) {
return `@import '${
isWin ? relativeImportPath.replace('\\', '/') : relativeImportPath
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Option glob.windowsPathsNoEscape instructs replace-in-file to interpret Windows paths as-is and avoid escaping backslashes found in the value of the files argument, which on Windows leads to double escaping and yields an invalid glob pattern that will never match anything:

image

Example of a files value from the @carbon/grid build:

image

Successful @carbon/grid build after the fix:

image

Copy link

netlify bot commented Jan 30, 2025

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit e538eda
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/67d8613ff453170008be473d
😎 Deploy Preview https://deploy-preview-18488--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@nchevsky nchevsky marked this pull request as ready for review January 30, 2025 06:06
@nchevsky nchevsky requested a review from a team as a code owner January 30, 2025 06:06
Copy link

netlify bot commented Jan 30, 2025

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit 8351b46
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/67f786e751fe65000855596b
😎 Deploy Preview https://deploy-preview-18488--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@kennylam kennylam requested review from a team as code owners February 13, 2025 14:16
Copy link

codecov bot commented Feb 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.96%. Comparing base (0d0115b) to head (8351b46).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #18488   +/-   ##
=======================================
  Coverage   84.96%   84.96%           
=======================================
  Files         391      391           
  Lines       14490    14490           
  Branches     4741     4773   +32     
=======================================
  Hits        12312    12312           
- Misses       2029     2030    +1     
+ Partials      149      148    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tay1orjones
Copy link
Member

@nchevsky thanks for putting this up! Does the full monorepo build work now or just the grid package? In either case what do you think about adding a new step to the ci workflow that runs on windows and ensures the build passes? It wouldn't have to be a required check, but would provide visibility into the status of windows support without having to manually test on a windows machine.

@nchevsky
Copy link
Contributor Author

@nchevsky thanks for putting this up! Does the full monorepo build work now or just the grid package? In either case what do you think about adding a new step to the ci workflow that runs on windows and ensures the build passes? It wouldn't have to be a required check, but would provide visibility into the status of windows support without having to manually test on a windows machine.

@tay1orjones This PR only fixes cli and the dependent grid build. I have fixes for the rest of the monorepo, too, but I wanted to gauge interest before submitting the rest, as it takes significant effort to prepare each submision. There are quite a few remaining instances of bad path handling, and each needs a slightly different solution with an individual explanation. Now that this PR has been well-received, I can start preparing the rest. 🙂

That's a great idea about the build step! Unfortunately I'm spread very thin until April, but I'm happy to add that as we get closer to merging the last couple of path handling fixes. Does that sound reasonable?

Copy link
Member

@annawen1 annawen1 left a comment

Choose a reason for hiding this comment

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

confirmed working on windows machine, @carbon/grid builds!

@preetibansalui preetibansalui added this pull request to the merge queue Apr 10, 2025
Merged via the queue into carbon-design-system:main with commit 517562c Apr 10, 2025
37 checks passed
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.

Carbon build is not working
5 participants