mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
8971e2feba
Adds electron-builder, which we will use to package and distribute our application, same as in the existing app. Replaces explicit port assignments with dynamic ones, which are then stored into environment variables. Adds a ~/.w2-dev folder for use when running a dev build. The build-helper pipeline from the old repo is included here too, but it is not updated yet so it will fail. Also removes some redundant utility functions and cleans up some let vs. const usage. The packaging can be run using the `package:prod` and `package:dev` tasks. --------- Co-authored-by: sawka <mike.sawka@gmail.com>
27 lines
726 B
TypeScript
27 lines
726 B
TypeScript
import { getApi } from "@/app/store/global";
|
|
|
|
function getWindow(): Window {
|
|
return globalThis.window;
|
|
}
|
|
|
|
function getProcess(): NodeJS.Process {
|
|
return globalThis.process;
|
|
}
|
|
|
|
/**
|
|
* Gets an environment variable from the host process, either directly or via IPC if called from the browser.
|
|
* @param paramName The name of the environment variable to attempt to retrieve.
|
|
* @returns The value of the environment variable or null if not present.
|
|
*/
|
|
export function getEnv(paramName: string): string {
|
|
const win = getWindow();
|
|
if (win != null) {
|
|
return getApi().getEnv(paramName);
|
|
}
|
|
const proc = getProcess();
|
|
if (proc != null) {
|
|
return proc.env[paramName];
|
|
}
|
|
return null;
|
|
}
|