Gate desktop daemon dev providers in production
This commit is contained in:
@@ -109,6 +109,7 @@ describe("node-entrypoint-launcher", () => {
|
|||||||
env: {
|
env: {
|
||||||
PATH: "/usr/bin",
|
PATH: "/usr/bin",
|
||||||
ELECTRON_RUN_AS_NODE: "1",
|
ELECTRON_RUN_AS_NODE: "1",
|
||||||
|
NODE_ENV: "production",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -134,6 +135,25 @@ describe("node-entrypoint-launcher", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("forces packaged launches to production even when NODE_ENV is inherited as development", () => {
|
||||||
|
expect(
|
||||||
|
createNodeEntrypointInvocation({
|
||||||
|
execPath: "/Applications/Paseo.app/Contents/MacOS/Paseo",
|
||||||
|
isPackaged: true,
|
||||||
|
packagedRunnerPath:
|
||||||
|
"/Applications/Paseo.app/Contents/Resources/app.asar/dist/daemon/node-entrypoint-runner.js",
|
||||||
|
entrypoint: CLI_ENTRYPOINT,
|
||||||
|
argvMode: "node-script",
|
||||||
|
args: [],
|
||||||
|
baseEnv: { PATH: "/usr/bin", NODE_ENV: "development" },
|
||||||
|
}).env,
|
||||||
|
).toMatchObject({
|
||||||
|
PATH: "/usr/bin",
|
||||||
|
ELECTRON_RUN_AS_NODE: "1",
|
||||||
|
NODE_ENV: "production",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("keeps node-style argv for packaged script entrypoints", () => {
|
it("keeps node-style argv for packaged script entrypoints", () => {
|
||||||
expect(
|
expect(
|
||||||
createNodeEntrypointInvocation({
|
createNodeEntrypointInvocation({
|
||||||
@@ -158,6 +178,7 @@ describe("node-entrypoint-launcher", () => {
|
|||||||
env: {
|
env: {
|
||||||
PATH: "/usr/bin",
|
PATH: "/usr/bin",
|
||||||
ELECTRON_RUN_AS_NODE: "1",
|
ELECTRON_RUN_AS_NODE: "1",
|
||||||
|
NODE_ENV: "production",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -31,10 +31,14 @@ type ParseCliPassthroughArgsFromArgvInput = {
|
|||||||
forceCli: boolean;
|
forceCli: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function createElectronNodeEnv(baseEnv: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
|
export function createElectronNodeEnv(
|
||||||
|
baseEnv: NodeJS.ProcessEnv,
|
||||||
|
options?: { isPackaged?: boolean },
|
||||||
|
): NodeJS.ProcessEnv {
|
||||||
return {
|
return {
|
||||||
...baseEnv,
|
...baseEnv,
|
||||||
ELECTRON_RUN_AS_NODE: "1",
|
ELECTRON_RUN_AS_NODE: "1",
|
||||||
|
...(options?.isPackaged === true ? { NODE_ENV: "production" } : {}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +65,7 @@ export function parseCliPassthroughArgsFromArgv(
|
|||||||
export function createNodeEntrypointInvocation(
|
export function createNodeEntrypointInvocation(
|
||||||
input: CreateNodeEntrypointInvocationInput,
|
input: CreateNodeEntrypointInvocationInput,
|
||||||
): NodeEntrypointInvocation {
|
): NodeEntrypointInvocation {
|
||||||
const env = createElectronNodeEnv(input.baseEnv);
|
const env = createElectronNodeEnv(input.baseEnv, { isPackaged: input.isPackaged });
|
||||||
|
|
||||||
if (input.isPackaged) {
|
if (input.isPackaged) {
|
||||||
if (!input.packagedRunnerPath) {
|
if (!input.packagedRunnerPath) {
|
||||||
|
|||||||
Reference in New Issue
Block a user