-
Notifications
You must be signed in to change notification settings - Fork 148
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
Handle env vars in a case-preserving, case-insensitive manner on Windows #574
Conversation
@niik Just making sure you were aware of the failing tests (I have been putting off reviewing till those are happy) |
I was not aware, thanks for the heads up! |
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 looks all good! Just have a question about one of the tests, not sure if it's 100% useful the way it is right now 🤔
test/fast/environment-test.ts
Outdated
@@ -53,11 +53,20 @@ describe('environment variables', () => { | |||
// case-insensitive (like Windows) we don't end up with an invalid PATH | |||
// and the original one lost in the process. | |||
const { env } = setupEnvironment({}) | |||
expect(env.PATH).toContain('wow-such-case-insensitivity') | |||
expect(env.Path).toContain('wow-such-case-insensitivity') |
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.
Shouldn't this be checking PATH
to prove it's case insensitive? 🤔 Or both…
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 boy, this was 5 months ago but I think this is correct albeit highly confusing. It's meant to test that on Windows the env map is case preserving but case insensitive. That said I tried to update the test to be more clear and found a bug in EnvMap's constructor. Happy for you to take another look now!
This is a follow-up to #570 and attempts to tackle Windows environment variable shenanigans for all environment variables and not just
PATH
. The main change is the introduction ofEnvMap
, a class that behaves as a case-insensitive, case-preserving map on Windows and a regular case-sensitive map on other platforms. This class is used inlib/git-environment.ts
to handle environment variables in a consistent manner across platforms.I've also bumped Prettier to 3.3.1 so it can handle my syntax and specified the version of TypeScript used by Visual Studio Code in
.vscode/settings.json
because I was building this on an old VM with an old VS code and noticed that it wouldn't complete properly.