Skip to content

Commit d5997f4

Browse files
committed
is-command-available win side
1 parent 756ded0 commit d5997f4

File tree

2 files changed

+41
-44
lines changed

2 files changed

+41
-44
lines changed

main.js

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -966,56 +966,53 @@ ipcMain.handle('install-flatpak', async (event, appId) => {
966966
});
967967

968968
ipcMain.handle('is-command-available', async (_event, commandName) => {
969-
return new Promise((resolve) => {
970-
const isWin = process.platform === 'win32';
971-
972-
if (!isWin) {
973-
// Linux / macOS fallback
974-
exec(`command -v ${commandName}`, (error, stdout) => {
975-
resolve(!error && stdout.trim().length > 0);
976-
});
977-
return;
978-
}
979-
980-
// WINDOWS PATH CHECK (fast)
981-
exec(`where.exe ${commandName}.exe`, (error, stdout) => {
982-
if (!error && stdout.trim().length > 0) {
983-
resolve(true);
984-
return;
985-
}
986-
987-
// WINDOWS MANUAL LOOKUP (common install dirs)
988-
const possibleDirs = [
989-
process.env["LOCALAPPDATA"] + "\\Programs",
990-
process.env["LOCALAPPDATA"],
991-
process.env["ProgramFiles"],
992-
process.env["ProgramFiles(x86)"],
993-
];
994-
995-
const fs = require('fs');
996-
const path = require('path');
969+
return new Promise((resolve) => {
970+
const isWin = process.platform === 'win32';
997971

998-
for (const dir of possibleDirs) {
999-
if (!dir) continue;
972+
if (!isWin) {
973+
// Linux / macOS fallback
974+
exec(`command -v ${commandName}`, (error, stdout) => {
975+
resolve(!error && stdout.trim().length > 0);
976+
});
977+
return;
978+
}
1000979

1001-
try {
1002-
// Simple directory scan, no recursion
1003-
const entries = fs.readdirSync(dir, { withFileTypes: true });
1004-
for (const entry of entries) {
1005-
if (entry.isDirectory()) {
1006-
const exePath = path.join(dir, entry.name, `${commandName}.exe`);
1007-
if (fs.existsSync(exePath)) {
980+
// WINDOWS PATH CHECK (fast)
981+
exec(`where.exe ${commandName}.exe`, (error, stdout) => {
982+
if (!error && stdout.trim().length > 0) {
1008983
resolve(true);
1009984
return;
1010-
}
1011985
}
1012-
}
1013-
} catch (_) {}
1014-
}
1015986

1016-
resolve(false); // Not found anywhere
987+
// WINDOWS MANUAL LOOKUP (common install dirs)
988+
const possibleDirs = [
989+
process.env["LOCALAPPDATA"] + "\\Programs",
990+
process.env["LOCALAPPDATA"],
991+
process.env["ProgramFiles"],
992+
process.env["ProgramFiles(x86)"],
993+
];
994+
995+
for (const dir of possibleDirs) {
996+
if (!dir) continue;
997+
998+
try {
999+
// Simple directory scan, no recursion
1000+
const entries = fs.readdirSync(dir, { withFileTypes: true });
1001+
for (const entry of entries) {
1002+
if (entry.isDirectory()) {
1003+
const exePath = path.join(dir, entry.name, `${commandName}.exe`);
1004+
if (fs.existsSync(exePath)) {
1005+
resolve(true);
1006+
return;
1007+
}
1008+
}
1009+
}
1010+
} catch (_) {}
1011+
}
1012+
1013+
resolve(false); // Not found anywhere
1014+
});
10171015
});
1018-
});
10191016
});
10201017

10211018

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "emulsion",
3-
"version": "0.9.90",
3+
"version": "0.9.91",
44
"summary": "Better gaming throught chemistry",
55
"description": "Display your games collection into responsive galleries, manage game metadata, cover art and emulator configuration. Launch your games in style.",
66
"homepage": "https://yphil.gitlab.io/emulsion",

0 commit comments

Comments
 (0)