improve macOS path resolution for app bundles (#632)

This commit is contained in:
Stephen Bell
2024-04-30 09:55:52 +10:00
committed by GitHub
parent 6b009ea123
commit df445b8390

View File

@@ -1,6 +1,7 @@
import * as vscode from "vscode";
import * as path from "path";
import * as fs from "fs";
import * as os from "os";
import { execSync } from "child_process";
import { get_configuration } from "./vscode_utils";
@@ -109,6 +110,10 @@ type VERIFY_RESULT = {
export function verify_godot_version(godotPath: string, expectedVersion: "3" | "4" | string): VERIFY_RESULT {
try {
if (os.platform() === 'darwin' && godotPath.endsWith('.app')) {
godotPath = path.join(godotPath, 'Contents', 'MacOS', 'Godot');
}
const output = execSync(`"${godotPath}" --version`).toString().trim();
const pattern = /^(([34])\.([0-9]+)(?:\.[0-9]+)?)/m;
const match = output.match(pattern);