fix: rename product executable on macOS (#291948)

* fix: rename product executable name on macOS

* chore: update test/automation/src/electron.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: update test/automation/src/electron.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: rename in additional places

* chore: rename in code-perf.js

* chore: create symlink for backwards compatibility

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Robo
2026-02-04 07:50:21 +09:00
committed by GitHub
parent 1296bc9947
commit d0e516655a
18 changed files with 91 additions and 21 deletions

View File

@@ -121,13 +121,22 @@ function findFilePath(root: string, path: string): string {
throw new Error(`Could not find ${path} in any subdirectory`);
}
function parseVersion(version: string) {
const match = /^(\d+)\.(\d+)\.(\d+)/.exec(version);
if (!match) {
throw new Error(`Invalid version string: ${version}`);
}
const [, major, minor, patch] = match;
return { major: parseInt(major), minor: parseInt(minor), patch: parseInt(patch) };
}
export function getDevElectronPath(): string {
const buildPath = join(root, '.build');
const product = require(join(root, 'product.json'));
switch (process.platform) {
case 'darwin':
return join(buildPath, 'electron', `${product.nameLong}.app`, 'Contents', 'MacOS', 'Electron');
return join(buildPath, 'electron', `${product.nameLong}.app`, 'Contents', 'MacOS', `${product.nameShort}`);
case 'linux':
return join(buildPath, 'electron', `${product.applicationName}`);
case 'win32':
@@ -139,8 +148,20 @@ export function getDevElectronPath(): string {
export function getBuildElectronPath(root: string): string {
switch (process.platform) {
case 'darwin':
return join(root, 'Contents', 'MacOS', 'Electron');
case 'darwin': {
const packageJson = require(join(root, 'Contents', 'Resources', 'app', 'package.json'));
const product = require(join(root, 'Contents', 'Resources', 'app', 'product.json'));
const { major, minor } = parseVersion(packageJson.version);
// For macOS builds using the legacy Electron binary name, versions up to and including
// 1.109.x ship the executable as "Electron". From later versions onward, the executable
// is renamed to match product.nameShort. This check preserves compatibility with older
// builds; update the cutoff here only if the binary naming scheme changes again.
if (major === 1 && minor <= 109) {
return join(root, 'Contents', 'MacOS', 'Electron');
} else {
return join(root, 'Contents', 'MacOS', product.nameShort);
}
}
case 'linux': {
const product = require(join(root, 'resources', 'app', 'product.json'));
return join(root, product.applicationName);

View File

@@ -196,7 +196,7 @@ async function ensureStableCode(): Promise<void> {
}));
if (process.platform === 'darwin') {
// Visual Studio Code.app/Contents/MacOS/Electron
// Visual Studio Code.app/Contents/MacOS/Code
stableCodePath = path.dirname(path.dirname(path.dirname(stableCodeExecutable)));
} else {
// VSCode/Code.exe (Windows) | VSCode/code (Linux)

View File

@@ -779,18 +779,22 @@ export class TestContext {
switch (os.platform()) {
case 'darwin': {
let appName: string;
let binaryName: string;
switch (this.options.quality) {
case 'stable':
appName = 'Visual Studio Code.app';
binaryName = 'Code';
break;
case 'insider':
appName = 'Visual Studio Code - Insiders.app';
binaryName = 'Code - Insiders';
break;
case 'exploration':
appName = 'Visual Studio Code - Exploration.app';
binaryName = 'Code - Exploration';
break;
}
filePath = path.join(dir, appName, 'Contents/MacOS/Electron');
filePath = path.join(dir, appName, 'Contents/MacOS', binaryName);
break;
}
case 'linux': {

View File

@@ -322,7 +322,7 @@ async function ensureStableCode(): Promise<void> {
});
if (process.platform === 'darwin') {
// Visual Studio Code.app/Contents/MacOS/Electron
// Visual Studio Code.app/Contents/MacOS/Code
stableCodePath = path.dirname(path.dirname(path.dirname(stableCodeExecutable)));
} else {
// VSCode/Code.exe (Windows) | VSCode/code (Linux)