10000 Fix file URI handling for Windows platforms by EvilGenius13 · Pull Request #835 · Shopify/theme-tools · GitHub
[go: up one dir, main page]

Skip to content
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

Fix file URI handling for Windows platforms #835

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

EvilGenius13
Copy link
Contributor
@EvilGenius13 EvilGenius13 commented Feb 28, 2025

What are you adding in this PR?

Part of Shopify/cli#3497

After a long debugging session and some async work with @aswamy, we found where the issue was coming from.

On windows platforms, filepaths look something like this file:\\\C:\path\to\file.

  • After normalization, it looks like /C:/path/to/file
  • When this glob is provided for asyncGlob on Windows, it gets confused because of the leading /
  • We strip that leading / if it exists before a path

This implementation checks if the OS is windows before changing the way we change the URI to ensure we don't affect unix based systems.

Before you deploy

  • I included a patch bump changeset

@aswamy aswamy marked this pull request as ready for review March 11, 2025 20:37
@aswamy aswamy requested a review from a team as a code owner March 11, 2025 20:37
@aswamy aswamy requested a review from karreiro March 11, 2025 20:37
// start with a drive letter (with few exceptions we can ignore).
// More info: https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats
//
// If an absoluate path starts with a slash on Windows, we strip it
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add a test for this? Is there a reasonable way to accomplish that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add a test for this?

Will do!

Is there a reasonable way to accomplish that?

We can't tophat this in a reasonable way because we have to release theme-tools FIRST then update CLI. To verify this works i installed CLI on my windows machine, then updated its source code to contain this change.

Co-authored-by: Josh Faigan <josh.faigan@shopify.com>
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