-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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(gatsby): ensure that writing node manifests to disk does not break on Windows #33853
Conversation
@@ -239,14 +239,28 @@ export async function processNodeManifest( | |||
const gatsbySiteDirectory = store.getState().program.directory | |||
|
|||
// write out the manifest file | |||
const manifestFilePath = path.join( | |||
let manifestFilePath = path.join( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we use joinPath here? https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-core-utils/src/path.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like it handles :
's
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm down but I'm curious, what does this quadruple backslash do for us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, also it won't solve this issue on its own (doesn't handle :
like @TylerBarnes said). But if it gives us some extra guardrails for other scenarios using it makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, got it, @KyleAMathews I thought you meant can we use it to solve this problem. I see you mean for extra edge-case guards like @veryspry is saying. Makes sense!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I should have been more direct — this is the utility we use all over core for creating cross-os paths (https://github.com/gatsbyjs/gatsby/search?q=joinPath) — I forget its whole history but it should be pretty battle-tested now.
I see now better what you're solving e.g. that some manifest IDs can have reserved characters in them. Wouldn't we always need to replace those? There's some others we'd need to handle https://superuser.com/questions/358855/what-characters-are-safe-in-cross-platform-file-names-for-linux-windows-and-os
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha! I'll make that change
Yes, we probably do need to handle more characters other than the colon. :
is probably the most pressing since a node manifest file name will likely be created using a timestamp but I'll look into handling other cases as well,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the change to use joinPath
like you suggested.
Also added some more chars to the replace regex to account for other special chars on Windows
749738c
to
57a733d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heck yes! 💪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the processNodeManifest tests need to be updated to pass on windows
I wonder if we shouldn't use
I might be missing something though |
I tested on a Windows machine with this canary and node manifests were written correctly to disk
|
Sweet 😄 I guess we just need to use |
Oh NVM, I did not confirm that conclusively. Looks like there was a webpack error during build time that must have prevented the files from getting written to disk? The log saying that the files were successfully written running though 🤔 I need to head out for the night but I will dig in some more in the morning |
I'm pretty sure that this is okay since the extra backslashes should be ignored as redundant escape chars. I'm guessing the use of four |
873ffce
to
ea64f94
Compare
joinPath is only necessary when you use it in a string, here it's actually useless. I wonder why we don't use |
@wardpeet Aha, that makes sense. I'm going to revert it then in favor of On another note, we really should only be running the replace function on the filename, not the whole path. That way we can also replace any instances of |
Oh yes only on the filename not full path 👍. This more or less removes os specific code |
Description
Writing node manifest files is failing on Windows and this provides a fix for that.
Related Issues
Resolves #33743