fix: inheriting NODE_OPTIONS on macOS with integrated terminal (#204682)

This commit is contained in:
Robo 2024-02-09 03:02:19 +09:00 committed by GitHub
parent 249a9514f2
commit cfb7370855
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 1 deletions

View File

@ -31,5 +31,9 @@ fi
CONTENTS="$APP_PATH/Contents"
ELECTRON="$CONTENTS/MacOS/Electron"
CLI="$CONTENTS/Resources/app/out/cli.js"
export VSCODE_NODE_OPTIONS=$NODE_OPTIONS
export VSCODE_NODE_REPL_EXTERNAL_MODULE=$NODE_REPL_EXTERNAL_MODULE
unset NODE_OPTIONS
unset NODE_REPL_EXTERNAL_MODULE
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
exit $?

View File

@ -13,7 +13,7 @@ import { IWorkspaceContextService, IWorkspaceFolder } from 'vs/platform/workspac
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import { sanitizeProcessEnvironment } from 'vs/base/common/processes';
import { IShellLaunchConfig, ITerminalBackend, ITerminalEnvironment, TerminalShellType, WindowsShellType } from 'vs/platform/terminal/common/terminal';
import { IProcessEnvironment, isWindows, language, OperatingSystem } from 'vs/base/common/platform';
import { IProcessEnvironment, isWindows, isMacintosh, language, OperatingSystem } from 'vs/base/common/platform';
import { escapeNonWindowsPath, sanitizeCwd } from 'vs/platform/terminal/common/terminalEnvironment';
import { isString } from 'vs/base/common/types';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
@ -269,6 +269,26 @@ export async function createTerminalEnvironment(
}
}
// Workaround for https://github.com/microsoft/vscode/issues/204005
// We should restore the following environment variables when a user
// launches the application using the CLI so that integrated terminal
// can still inherit these variables.
// We are not bypassing the restrictions implied in https://github.com/electron/electron/pull/40770
// since this only affects integrated terminal and not the application itself.
if (isMacintosh) {
// Restore NODE_OPTIONS if it was set
if (env['VSCODE_NODE_OPTIONS']) {
env['NODE_OPTIONS'] = env['VSCODE_NODE_OPTIONS'];
delete env['VSCODE_NODE_OPTIONS'];
}
// Restore NODE_REPL_EXTERNAL_MODULE if it was set
if (env['VSCODE_NODE_REPL_EXTERNAL_MODULE']) {
env['NODE_REPL_EXTERNAL_MODULE'] = env['VSCODE_NODE_REPL_EXTERNAL_MODULE'];
delete env['VSCODE_NODE_REPL_EXTERNAL_MODULE'];
}
}
// Sanitize the environment, removing any undesirable VS Code and Electron environment
// variables
sanitizeProcessEnvironment(env, 'VSCODE_IPC_HOOK_CLI');