mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-19 05:12:16 +03:00
fix(cli): skip POSIX path lookup on Windows autostart (#12993)
* fix(cli): skip POSIX path lookup on Windows autostart * docs(changelog): record Windows autostart path fix
This commit is contained in:
@@ -13,11 +13,13 @@ const LINUX_DESKTOP_NAME = "omniroute.desktop";
|
||||
function resolveCliPath() {
|
||||
const candidates = [];
|
||||
if (process.argv[1]) candidates.push(process.argv[1]);
|
||||
try {
|
||||
const which = execSync("command -v omniroute 2>/dev/null", { encoding: "utf8" }).trim();
|
||||
if (which) candidates.push(which);
|
||||
} catch {
|
||||
// command -v unavailable
|
||||
if (process.platform !== "win32") {
|
||||
try {
|
||||
const which = execSync("command -v omniroute 2>/dev/null", { encoding: "utf8" }).trim();
|
||||
if (which) candidates.push(which);
|
||||
} catch {
|
||||
// command -v unavailable
|
||||
}
|
||||
}
|
||||
candidates.push(join(dirname(fileURLToPath(import.meta.url)), "..", "..", "omniroute.mjs"));
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
- **fix(cli):** skip the POSIX CLI path lookup during Windows autostart setup, preventing a bogus path error before successful enablement ([#12993](https://github.com/diegosouzapw/OmniRoute/pull/12993))
|
||||
@@ -69,6 +69,23 @@ test("Windows enable/disable writes and removes VBS in Startup folder", async ()
|
||||
// autostart-macos-launchctl.test.ts.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test("Windows path resolution skips the POSIX command lookup", () => {
|
||||
const source = readFileSync(join(process.cwd(), "bin/cli/tray/autostart.mjs"), "utf8");
|
||||
const resolveCliPath = source.match(/function resolveCliPath\(\) \{([\s\S]*?)\n\}/);
|
||||
|
||||
assert.ok(resolveCliPath, "resolveCliPath should exist");
|
||||
const nonWindowsGuard = resolveCliPath[1].match(
|
||||
/if \(process\.platform !== "win32"\) \{([\s\S]*?)\n \}/
|
||||
);
|
||||
assert.ok(nonWindowsGuard, "resolveCliPath should have a non-Windows guard");
|
||||
assert.match(nonWindowsGuard[1], /command -v omniroute/);
|
||||
assert.doesNotMatch(
|
||||
resolveCliPath[1].replace(nonWindowsGuard[0], ""),
|
||||
/command -v omniroute/,
|
||||
"the POSIX PATH probe must only appear inside the non-Windows guard"
|
||||
);
|
||||
});
|
||||
|
||||
test("Windows enableWin writes VBS to Startup folder, not reg add", () => {
|
||||
const source = readFileSync(join(process.cwd(), "bin/cli/tray/autostart.mjs"), "utf8");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user