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 absolute path handling for config validation in windows #7704

Merged
merged 2 commits into from Jul 19, 2023

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jul 18, 2023

Changes

Fix passing absolute paths to root, srcDir, publicDir, outDir, cacheDir, build.client, and build.server on Windows. We currently have code like this:

.transform((val) => new URL(appendForwardSlash(val), fileProtocolRoot)),

And they fail on Windows because val looks like C:\\User\\bob. The C: looks like a protocol when passed to new URL and that creates an invalid final URL. Switching to path.resolve fixes this for now.

Testing

Tested in #7682 where I passed the absolute root path in tests, and it failed. The fa32ff0 commit there fixes it, which I ported it to here to main first.

Besides that, no actual tests here yet, but CI should continue to pass.

Also thanks @hippotastic for testing that this works.

Docs

The docs for srcDir, publicDir, outDir, and cacheDir mentioned that they accept absolute paths. root, build.client, and build.server don't exactly mention it, but it would be nice if they work still for consistency.

@changeset-bot
Copy link

changeset-bot bot commented Jul 18, 2023

🦋 Changeset detected

Latest commit: b59fc08

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jul 18, 2023
@bluwy bluwy merged commit d78db48 into main Jul 19, 2023
13 checks passed
@bluwy bluwy deleted the fix-validation-windows branch July 19, 2023 07:53
@astrobot-houston astrobot-houston mentioned this pull request Jul 19, 2023
@Geoffrey-Pliez
Copy link
Contributor

Geoffrey-Pliez commented Oct 19, 2023

Hi,

Is it normal for the pathname of these paths to start with "/" on Windows?
Because it doesn't allow you to use the pathname in other projects like this one

@bluwy
Copy link
Member Author

bluwy commented Oct 19, 2023

I don't think that's common on Windows. If you're dabbling with path file: URLs, you should use fileUrlToPath or pathToFileUrl to make sure they work across OS.

@Geoffrey-Pliez
Copy link
Contributor

Ok, I'll try to explore the idea.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants