Skip to content

Commit

Permalink
chore: use env for windows and linux
Browse files Browse the repository at this point in the history
Just updates windows and linux to use PD env API instead of os.platform(), so that
it is consistent with mac. Tests mock to mac for now, as they're not doing anything
dependent on execution OS.

Fixes #1207.

Signed-off-by: Tim deBoer <[email protected]>
  • Loading branch information
deboer-tim committed Jan 30, 2025
1 parent 038ab6c commit ea3f3da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 6 additions & 1 deletion packages/backend/src/machine-utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**********************************************************************
* Copyright (C) 2024 Red Hat, Inc.
* Copyright (C) 2024-2025 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,6 +51,11 @@ vi.mock('@podman-desktop/api', async () => {
};
},
},
env: {
isMac: true,
isLinux: false,
isWindows: false,
},
process: {
exec: vi.fn(),
},
Expand Down
8 changes: 3 additions & 5 deletions packages/backend/src/machine-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**********************************************************************
* Copyright (C) 2024 Red Hat, Inc.
* Copyright (C) 2024-2025 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -165,14 +165,12 @@ function getCustomBinaryPath(): string | undefined {
return extensionApi.configuration.getConfiguration('podman').get('binary.path');
}

const windows = os.platform() === 'win32';
export function isWindows(): boolean {
return windows;
return env.isWindows;
}

const linux = os.platform() === 'linux';
export function isLinux(): boolean {
return linux;
return env.isLinux;
}

export function isMac(): boolean {
Expand Down

0 comments on commit ea3f3da

Please sign in to comment.