Skip to content

Commit

Permalink
feat: check for additional install paths on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
hverlin committed Dec 16, 2024
1 parent b3c5a02 commit 45bd1dc
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions src/utils/miseBinLocator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as fs from "node:fs/promises";
import * as os from "node:os";
import * as path from "node:path";
import { getConfiguredBinPath } from "../configuration";
Expand All @@ -24,23 +23,46 @@ export async function resolveMisePath(): Promise<string> {
return result.stdout.trim();
}

if (process.platform === "win32") {
const result = await safeExec("where.exe", ["mise"]);
logger.info(`where mise: ${result.stdout}`);
const firstEntry = result.stdout.split("\r\n")?.[0];
if (firstEntry) {
return firstEntry.trim();
}
}

// Check common installation locations
const homedir = os.homedir();
const commonPaths = [
path.join(homedir, ".local", "bin", "mise"), // ~/.local/bin/mise
path.join(homedir, "bin", "mise"), // ~/bin/mise
path.join(homedir, ".local", "bin", "mise"),
path.join(homedir, "bin", "mise"),
];

if (process.platform !== "win32") {
commonPaths.push(
"/usr/local/bin/mise",
"/opt/homebrew/bin/mise", // Homebrew
path.join("/usr", "local", "bin", "mise"),
path.join("/opt", "homebrew", "bin", "mise"),
);
}

if (process.platform === "win32") {
commonPaths.push(path.join(homedir, "scoop", "shims", "mise"));
commonPaths.push(path.join(homedir, "scoop", "shims", "mise.exe"));
commonPaths.push(
path.join("C:", "ProgramData", "chocolatey", "bin", "mise.exe"),
);
commonPaths.push(path.join("C:", "Program Files", "mise", "mise.exe"));
commonPaths.push(
path.join(
homedir,
"AppData",
"Local",
"Microsoft",
"WinGet",
"Links",
"mise.exe",
),
);
}

const allPaths = [...commonPaths];
Expand Down

0 comments on commit 45bd1dc

Please sign in to comment.