Skip to content

Commit

Permalink
[IMP] client: recursive evaluation of addon/odoo path in parent dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
mmahrouss committed Nov 12, 2024
1 parent 6f4f9c5 commit e95932e
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions vscode/client/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,18 @@ export async function fillTemplate(template, vars = {}) {
}

export async function validateAddonPath(addonPath) {
const workspaceFolders = workspace.workspaceFolders;
addonPath = addonPath.replaceAll("\\", "/");
for (const i in workspaceFolders) {
const folder = workspaceFolders[i];
for (const folder of workspace.workspaceFolders) {
const PATH_VAR_LOCAL = { ...global.PATH_VARIABLES };
PATH_VAR_LOCAL["workspaceFolder"] = folder.uri.fsPath.replaceAll("\\", "/");
const filledPath = path.resolve(await fillTemplate(addonPath, PATH_VAR_LOCAL)).replaceAll("\\", "/");
if (filledPath && isAddonPath(filledPath)) {
return filledPath;
}
let filledPath = path.resolve(await fillTemplate(addonPath, PATH_VAR_LOCAL)).replaceAll("\\", "/");
if (!filledPath) continue;
do {
if (isAddonPath(filledPath)) {
return filledPath;
}
filledPath = path.dirname(filledPath);
} while (path.parse(filledPath).root != filledPath);
}
return null;
}
Expand All @@ -93,18 +95,19 @@ export async function evaluateOdooPath(odooPath) {
if (!odooPath) {
return
}
const workspaceFolders = workspace.workspaceFolders;
odooPath = odooPath.replaceAll("\\", "/");


for (const i in workspaceFolders) {
const folder = workspaceFolders[i];
for (const folder of workspace.workspaceFolders) {
global.PATH_VARIABLES["workspaceFolder"] = folder.uri.fsPath.replaceAll("\\", "/");
const filledOdooPath = path.resolve(await fillTemplate(odooPath, global.PATH_VARIABLES)).replaceAll("\\", "/");
const version = await getOdooVersion(filledOdooPath);
if (version) {
return { "path": filledOdooPath, "version": version };
}
let filledOdooPath = path.resolve(await fillTemplate(odooPath, global.PATH_VARIABLES)).replaceAll("\\", "/");
do {
const version = await getOdooVersion(filledOdooPath);
if (version) {
return { "path": filledOdooPath, "version": version };
}
filledOdooPath = path.dirname(filledOdooPath);
} while (path.parse(filledOdooPath).root != filledOdooPath);
}
return null;
}
Expand Down

0 comments on commit e95932e

Please sign in to comment.