mirror of
https://github.com/bitwarden/browser
synced 2025-12-31 15:43:28 +00:00
chore(dev): Switch to using build constant for isDev check
This commit is contained in:
8
apps/desktop/src/global.d.ts
vendored
8
apps/desktop/src/global.d.ts
vendored
@@ -1,2 +1,10 @@
|
||||
declare module "forcefocus";
|
||||
declare const ipc: typeof import("./preload").ipc;
|
||||
|
||||
/**
|
||||
* Will be turned into a constant string in the main process only
|
||||
* likely either `"development"` or `"production"`.
|
||||
*
|
||||
* This is done using the `DefinePlugin` in our webpack files.
|
||||
*/
|
||||
declare const BIT_ENVIRONMENT: string;
|
||||
|
||||
@@ -15,7 +15,7 @@ jest.mock("@bitwarden/desktop-napi", () => {
|
||||
|
||||
describe("ElectronLogMainService", () => {
|
||||
it("sets dev based on electron method", () => {
|
||||
process.env.ELECTRON_IS_DEV = "1";
|
||||
globalThis.BIT_ENVIRONMENT = "development";
|
||||
const logService = new ElectronLogMainService();
|
||||
expect(logService).toEqual(expect.objectContaining({ isDev: true }) as any);
|
||||
});
|
||||
|
||||
@@ -20,11 +20,7 @@ export function invokeMenu(menu: RendererMenuItem[]) {
|
||||
}
|
||||
|
||||
export function isDev() {
|
||||
// ref: https://github.com/sindresorhus/electron-is-dev
|
||||
if ("ELECTRON_IS_DEV" in process.env) {
|
||||
return parseInt(process.env.ELECTRON_IS_DEV, 10) === 1;
|
||||
}
|
||||
return process.defaultApp || /node_modules[\\/]electron[\\/]/.test(process.execPath);
|
||||
return BIT_ENVIRONMENT === "development";
|
||||
}
|
||||
|
||||
export function isLinux() {
|
||||
|
||||
Reference in New Issue
Block a user