Remove top-level global for base directory (#7674)

This PR removes the top-level global variable for the base directory and replaces it with a module-level variable managed through a setter function. Key changes include removing the global declaration in lib/global.ts, introducing a local ce_base_directory variable and setBaseDirectory function in lib/assert.ts, and updating app.ts to use the new setter.

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Matt Godbolt
2025-05-11 19:28:04 -05:00
committed by GitHub
parent fac3bf59c1
commit ad5bec7626
5 changed files with 250 additions and 13 deletions

5
app.ts
View File

@@ -52,7 +52,7 @@ import systemdSocket from 'systemd-socket';
import _ from 'underscore';
import urljoin from 'url-join';
import {unwrap} from './lib/assert.js';
import {setBaseDirectory, unwrap} from './lib/assert.js';
import * as aws from './lib/aws.js';
import * as normalizer from './lib/clientstate-normalizer.js';
import {GoldenLayoutRootStruct} from './lib/clientstate-normalizer.js';
@@ -89,8 +89,7 @@ import {ElementType} from './shared/common-utils.js';
import {CompilerInfo} from './types/compiler.interfaces.js';
import type {Language, LanguageKey} from './types/languages.interfaces.js';
// Used by assert.ts
global.ce_base_directory = new URL('.', import.meta.url);
setBaseDirectory(new URL('.', import.meta.url));
(nopt as any).invalidHandler = (key: string, val: unknown, types: unknown[]) => {
logger.error(