diff --git a/tools/cli/commands.js b/tools/cli/commands.js index 10e6c52229..ef9d4f1810 100644 --- a/tools/cli/commands.js +++ b/tools/cli/commands.js @@ -263,17 +263,20 @@ export function parseRunTargets(targets) { export function getMeteorConfig(appDir) { if (global.meteorConfig) return global.meteorConfig; - const packageJsonPath = files.pathJoin(appDir, 'package.json'); - if (!files.exists(packageJsonPath)) { - return false; + let packageJson; + if (appDir) { + const packageJsonPath = files.pathJoin(appDir, 'package.json'); + if (!files.exists(packageJsonPath)) { + return false; + } + const packageJsonFile = files.readFile(packageJsonPath, 'utf8'); + packageJson = JSON.parse(packageJsonFile); } - const packageJsonFile = files.readFile(packageJsonPath, 'utf8'); - const packageJson = JSON.parse(packageJsonFile); - const meteorConfig = { + const modernForced = JSON.parse(process.env.METEOR_MODERN || "false"); + global.meteorConfig = { ...(packageJson?.meteor || {}), - modern: projectContextModule.normalizeModern(projectContextModule.modernForced || packageJson?.meteor?.modern), + modern: projectContextModule.normalizeModern(modernForced || packageJson?.meteor?.modern || false), }; - global.meteorConfig = meteorConfig; return global.meteorConfig; } diff --git a/tools/cli/main.js b/tools/cli/main.js index 48c5e4e16a..f890f272a4 100644 --- a/tools/cli/main.js +++ b/tools/cli/main.js @@ -865,9 +865,9 @@ makeGlobalAsyncLocalStorage().run({}, async function () { var appDir = files.findAppDir(); if (appDir) { appDir = files.pathResolve(appDir); - // Initialize meteorConfig globally for command context - global.meteorConfig = getMeteorConfig(appDir); } + // Initialize meteorConfig globally for command context + global.meteorConfig = getMeteorConfig(appDir); await require('../tool-env/isopackets.js').ensureIsopacketsLoadable(); diff --git a/tools/project-context.js b/tools/project-context.js index 31075cc4ce..481279439e 100644 --- a/tools/project-context.js +++ b/tools/project-context.js @@ -1788,8 +1788,6 @@ export const normalizeModern = (r = false) => Object.fromEntries( ]), ); -export const modernForced = JSON.parse(process.env.METEOR_MODERN || "false"); - export class MeteorConfig { constructor({ appDirectory, @@ -1834,11 +1832,12 @@ export class MeteorConfig { }, }), } : this._config; + const modernForced = JSON.parse(process.env.METEOR_MODERN || "false"); // Reinitialize meteorConfig globally for project context // Updates config when package.json changes trigger rebuilds global.meteorConfig = { ...(this._config || {}), - modern: normalizeModern(modernForced || this._config?.modern), + modern: normalizeModern(modernForced || this._config?.modern || false), }; return this._config; }