Skip to content

Commit 64ca7d3

Browse files
committed
feat(vscode): automatic GitHub install fallback in Setup; bump to 0.2.6
1 parent 01745d7 commit 64ca7d3

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

vscode-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ecocode-vscode",
33
"displayName": "EcoCode Insights",
44
"description": "Live-ish repository energy/performance insights powered by EcoCode CLI",
5-
"version": "0.2.5",
5+
"version": "0.2.6",
66
"publisher": "ecocode",
77
"icon": "media/Ecocode.png",
88
"repository": {

vscode-extension/src/extension.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,28 +389,29 @@ class EcoCodeController implements vscode.WebviewViewProvider {
389389
const globalInstallRoot = getGlobalInstallRoot();
390390
const venvPath = path.join(globalInstallRoot, "venv");
391391
const installSource = loadSettings().installSource;
392+
const gitFallback = "git+https://github.com/LeonardLeroy/EcoCode.git";
392393

393394
// Strategy (both OSes): use pipx when available (isolated, on PATH, PEP 668-safe);
394395
// otherwise create a dedicated venv. `-U` / `--force` make re-running upgrade the CLI.
395396
const setupCommand = isWindows
396397
? [
397398
`if (Get-Command pipx -ErrorAction SilentlyContinue) {`,
398-
` pipx install --force "${installSource}"`,
399+
` pipx install --force "${installSource}"; if ($LASTEXITCODE -ne 0) { pipx install --force "${gitFallback}" }`,
399400
`} else {`,
400401
` New-Item -ItemType Directory -Force -Path "${globalInstallRoot}" | Out-Null;`,
401402
` if (Get-Command py -ErrorAction SilentlyContinue) { py -3 -m venv "${venvPath}" } else { python -m venv "${venvPath}" };`,
402403
` & "${globalPythonPath}" -m pip install --upgrade pip;`,
403-
` & "${globalPythonPath}" -m pip install -U "${installSource}"`,
404+
` & "${globalPythonPath}" -m pip install -U "${installSource}"; if ($LASTEXITCODE -ne 0) { & "${globalPythonPath}" -m pip install -U "${gitFallback}" }`,
404405
`}`,
405406
].join(" ")
406407
: [
407408
`if command -v pipx >/dev/null 2>&1; then`,
408-
` pipx install --force "${installSource}";`,
409+
` pipx install --force "${installSource}" || pipx install --force "${gitFallback}";`,
409410
`else`,
410411
` mkdir -p "${globalInstallRoot}";`,
411412
` python3 -m venv "${venvPath}" || python -m venv "${venvPath}";`,
412413
` "${globalPythonPath}" -m pip install --upgrade pip;`,
413-
` "${globalPythonPath}" -m pip install -U "${installSource}";`,
414+
` "${globalPythonPath}" -m pip install -U "${installSource}" || "${globalPythonPath}" -m pip install -U "${gitFallback}";`,
414415
`fi`,
415416
].join(" ");
416417

0 commit comments

Comments
 (0)