|
@@ -2,6 +2,7 @@ import * as vscode from "vscode";
|
|
|
import * as path from "path";
|
|
|
import * as fs from "fs";
|
|
|
import { execSync } from "child_process";
|
|
|
+import { get_configuration } from "./vscode_utils";
|
|
|
|
|
|
let projectDir: string | undefined = undefined;
|
|
|
let projectFile: string | undefined = undefined;
|
|
@@ -21,7 +22,7 @@ export async function get_project_dir(): Promise<string | undefined> {
|
|
|
}
|
|
|
} else if (files.length > 1) {
|
|
|
// if multiple project files, pick the top-most one
|
|
|
- const best = files.reduce((a, b) => a.fsPath.length <= b.fsPath.length ? a : b);
|
|
|
+ const best = files.reduce((a, b) => (a.fsPath.length <= b.fsPath.length ? a : b));
|
|
|
if (best) {
|
|
|
file = best.fsPath;
|
|
|
if (!fs.existsSync(file) || !fs.statSync(file).isFile()) {
|
|
@@ -70,7 +71,7 @@ export async function get_project_version(): Promise<string | undefined> {
|
|
|
return projectVersion;
|
|
|
}
|
|
|
|
|
|
-export function find_project_file(start: string, depth: number = 20) {
|
|
|
+export function find_project_file(start: string, depth = 20) {
|
|
|
// TODO: rename this, it's actually more like "find_parent_project_file"
|
|
|
// This function appears to be fast enough, but if speed is ever an issue,
|
|
|
// memoizing the result should be straightforward
|
|
@@ -102,9 +103,9 @@ export async function convert_resource_path_to_uri(resPath: string): Promise<vsc
|
|
|
|
|
|
type VERIFY_STATUS = "SUCCESS" | "WRONG_VERSION" | "INVALID_EXE";
|
|
|
type VERIFY_RESULT = {
|
|
|
- status: VERIFY_STATUS,
|
|
|
- version?: string,
|
|
|
-}
|
|
|
+ status: VERIFY_STATUS;
|
|
|
+ version?: string;
|
|
|
+};
|
|
|
|
|
|
export function verify_godot_version(godotPath: string, expectedVersion: "3" | "4" | string): VERIFY_RESULT {
|
|
|
try {
|
|
@@ -122,3 +123,17 @@ export function verify_godot_version(godotPath: string, expectedVersion: "3" | "
|
|
|
return { status: "INVALID_EXE" };
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+export function clean_godot_path(godotPath: string): string {
|
|
|
+ const cleanPath = godotPath.replace(/^"/, "").replace(/"$/, "");
|
|
|
+ const resolvedPath = resolve_workspace_relative_path(cleanPath);
|
|
|
+ return resolvedPath;
|
|
|
+}
|
|
|
+
|
|
|
+function resolve_workspace_relative_path(target: string) {
|
|
|
+ if (!fs.existsSync(target)) {
|
|
|
+ const workspacePath = vscode.workspace.workspaceFolders[0].uri.fsPath;
|
|
|
+ return path.resolve(workspacePath, target);
|
|
|
+ }
|
|
|
+ return target;
|
|
|
+}
|