Remove use of __dirname from main process

This commit is contained in:
Fedor Indutny
2026-03-27 10:55:37 -07:00
committed by GitHub
parent 70f111e868
commit a048f83dbc
39 changed files with 222 additions and 337 deletions

View File

@@ -13,6 +13,7 @@ import {
parseEnvironment,
} from '../ts/environment.std.js';
import { createLogger } from '../ts/logging/log.std.js';
import { getAppRootDir } from '../ts/util/appRootDir.main.js';
const log = createLogger('config');
@@ -28,7 +29,6 @@ if (app.isPackaged) {
// Set environment vars to configure node-config before requiring it
process.env.NODE_ENV = getEnvironment();
process.env.NODE_CONFIG_DIR = join(__dirname, '..', 'config');
if (getEnvironment() === Environment.PackagedApp) {
// harden production config against the local env
@@ -43,8 +43,12 @@ if (getEnvironment() === Environment.PackagedApp) {
process.env.SIGNAL_CI_CONFIG = '';
process.env.GENERATE_PRELOAD_CACHE = '';
process.env.REACT_DEVTOOLS = '';
process.env.IS_BUNDLED = '1';
}
// Call `getAppRootDir()` after hardening since it relies on env variables
process.env.NODE_CONFIG_DIR = join(getAppRootDir(), 'config');
// We load config after we've made our modifications to NODE_ENV
// Note: we use `require()` because esbuild moves the imports to the top of
// the module regardless of their actual placement in the file.