Skip to content

Commit 9d65555

Browse files
committed
fix: validate that selected browser is installed
1 parent 1380d2b commit 9d65555

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

scripts/installed-browser-extensions.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ function readFile(path) {
1818
return ObjC.unwrap(str);
1919
}
2020

21+
const fileExists = (/** @type {string} */ filePath) => Application("Finder").exists(Path(filePath));
22+
2123
//──────────────────────────────────────────────────────────────────────────────
2224

2325
/** @type {Record<string, string>} */
@@ -37,6 +39,19 @@ function run() {
3739
const home = app.pathTo("home folder");
3840
const extensionPath = browserVars.extensionPath[browser].replace(/^~/, home);
3941

42+
// GUARD browser not installed
43+
if (!fileExists(extensionPath)) {
44+
return JSON.stringify({
45+
items: [
46+
{
47+
title: browser + " not installed.",
48+
subtitle: "⏎: Open workflow configuration to select a different browser.",
49+
arg: `alfredpreferences://navigateto/workflows>workflow>${$.getenv("alfred_workflow_uid")}>userconfig>browser`,
50+
},
51+
],
52+
});
53+
}
54+
4055
// SETTINGS
4156
const settings = JSON.parse(readFile("./scripts/all-chromium-browser-settings.json"));
4257
settings.push(...browserVars.settingsPages[browser]);

0 commit comments

Comments
 (0)