diff --git a/client/src/addon_manager/models/addon.ts b/client/src/addon_manager/models/addon.ts index abb91302635c4da84b6d44a34f5ef0cd5451598d..453855906653e6ee9805ae03e7dbffef0a30ee9f 100644 --- a/client/src/addon_manager/models/addon.ts +++ b/client/src/addon_manager/models/addon.ts @@ -80,9 +80,8 @@ export class Addon { /** Update this addon using git. */ public async update() { - const path = filesystem.getCorrectPath(this.uri); return git - .submoduleUpdate([path]) + .submoduleUpdate([this.uri.fsPath]) .then((message) => localLogger.debug(message)); } @@ -91,7 +90,7 @@ export class Addon { */ public checkIfEnabled(libraryPaths: string[]) { const regex = new RegExp( - `/sumneko.lua/addonManager/addons/${this.name}`, + `[\/\\\\]+sumneko.lua[\/\\\\]+addonManager[\/\\\\]+addons[\/\\\\]+${this.name}`, "g" ); @@ -138,9 +137,8 @@ export class Addon { } // Init submodule - const path = filesystem.getCorrectPath(this.uri); try { - await git.submoduleInit([path]); + await git.submoduleInit([this.uri.fsPath]); localLogger.debug("Initialized submodule"); } catch (e) { localLogger.error(e); @@ -148,7 +146,7 @@ export class Addon { } try { - await git.submoduleUpdate([path]); + await git.submoduleUpdate([this.uri.fsPath]); localLogger.debug("Submodule up to date"); } catch (e) { localLogger.error(e); @@ -157,7 +155,6 @@ export class Addon { // Apply addon settings const libraryUri = vscode.Uri.joinPath(this.uri, "module", "library"); - const libraryPath = filesystem.getCorrectPath(libraryUri); const configValues = await this.getConfigurationFile(); @@ -166,7 +163,7 @@ export class Addon { { action: "add", key: LIBRARY_SETTING, - value: libraryPath, + value: filesystem.unixifyPath(libraryUri), uri: folder.uri, }, ]); @@ -190,7 +187,7 @@ export class Addon { )) ?? []) as string[]; const regex = new RegExp( - `/sumneko.lua/addonManager/addons/${this.name}`, + `[\/\\\\]+sumneko.lua[\/\\\\]+addonManager[\/\\\\]+addons[\/\\\\]+${this.name}`, "g" ); const index = librarySetting.findIndex((path) => regex.test(path)); diff --git a/client/src/addon_manager/services/filesystem.service.ts b/client/src/addon_manager/services/filesystem.service.ts index 8ea68f355f24611e40582f2bb443e1d4da0b3a40..5928741ec678e3b08dc681b931e8e0a60bf4ffd3 100644 --- a/client/src/addon_manager/services/filesystem.service.ts +++ b/client/src/addon_manager/services/filesystem.service.ts @@ -13,8 +13,12 @@ type ReadDirectoryOptions = { namespace filesystem { - export function getCorrectPath(uri: vscode.Uri): string { - return platform() === "win32" ? uri.path.substring(1) : uri.fsPath; + export function unixifyPath(uri: vscode.Uri): string { + if (platform() === "win32") { + return uri.path.substring(1); + } else { + return uri.fsPath; + } } /** Check if a file exists diff --git a/client/src/addon_manager/services/git.service.ts b/client/src/addon_manager/services/git.service.ts index 2896befd42d1afa406349d6c0aefe6d9273e71a7..688eada4695c3922ff1664e7ed77467e0d5350a9 100644 --- a/client/src/addon_manager/services/git.service.ts +++ b/client/src/addon_manager/services/git.service.ts @@ -16,11 +16,9 @@ export const setupGit = async (context: vscode.ExtensionContext) => { ); await filesystem.createDirectory(storageURI); - const localRepoPath = filesystem.getCorrectPath(storageURI); - // set working directory try { - await git.cwd({ path: localRepoPath, root: true }); + await git.cwd({ path: storageURI.fsPath, root: true }); } catch (e) { localLogger.error(e); } @@ -32,10 +30,10 @@ export const setupGit = async (context: vscode.ExtensionContext) => { const options = { "--depth": 1 }; await git.clone( REPOSITORY_PATH, - localRepoPath, + storageURI.fsPath, options ); - localLogger.debug(`Cloned ${REPOSITORY_NAME} to ${localRepoPath}`); + localLogger.debug(`Cloned ${REPOSITORY_NAME} to ${storageURI.fsPath}`); } catch (e) { localLogger.error("Failed to clone repo!"); localLogger.error(e);