diff --git a/change/@azure-msal-node-extensions-be2bc48f-eda0-4092-8349-ef6f659fcf8d.json b/change/@azure-msal-node-extensions-be2bc48f-eda0-4092-8349-ef6f659fcf8d.json new file mode 100644 index 0000000000..ea97645960 --- /dev/null +++ b/change/@azure-msal-node-extensions-be2bc48f-eda0-4092-8349-ef6f659fcf8d.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix: Environment.getUserRootDirectory() only ever executes Windows code path", + "packageName": "@azure/msal-node-extensions", + "email": "janusz@corechain.tech", + "dependentChangeType": "patch" +} diff --git a/extensions/msal-node-extensions/src/utils/Environment.ts b/extensions/msal-node-extensions/src/utils/Environment.ts index b816114d9d..2d2692625f 100644 --- a/extensions/msal-node-extensions/src/utils/Environment.ts +++ b/extensions/msal-node-extensions/src/utils/Environment.ts @@ -57,7 +57,7 @@ export class Environment { } static getUserRootDirectory(): string | null { - return !this.isWindowsPlatform + return !this.isWindowsPlatform() ? this.getUserHomeDirOnUnix() : this.getUserHomeDirOnWindows(); } diff --git a/extensions/msal-node-extensions/test/utils/Environment.spec.ts b/extensions/msal-node-extensions/test/utils/Environment.spec.ts new file mode 100644 index 0000000000..96fce9c867 --- /dev/null +++ b/extensions/msal-node-extensions/test/utils/Environment.spec.ts @@ -0,0 +1,9 @@ +import { Environment } from "../../src/utils/Environment"; + +describe("Environment", () => { + test("Environment.isWindowsPlatform() should be called by Environment.getUserRootDirectory()", () => { + const spy = jest.spyOn(Environment, "isWindowsPlatform"); + Environment.getUserRootDirectory(); + expect(spy).toHaveBeenCalled(); + }); +});