-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
46 lines (40 loc) · 1.15 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const os = require("os");
const alfy = require("alfy");
const alfredNotifier = require("alfred-notifier");
const fs = require("fs");
// Checks for available update and updates the `info.plist`
alfredNotifier();
const userHomeDir = os.homedir();
const codeCachePath = `${userHomeDir}/Library/Application Support/Code/storage.json`;
const newCodeCachePath = `${userHomeDir}/Library/Application Support/Code/User/globalStorage/storage.json`;
let codeCacheJson;
try {
codeCacheJson = require(codeCachePath);
} catch (error) {
codeCacheJson = require(newCodeCachePath);
}
let emptyOutput = [];
try {
if (alfy.input) {
return;
}
emptyOutput = [...codeCacheJson.lastKnownMenubarData.menus.File.items]
.find(({ label }) => label === "Open &&Recent")
.submenu.items.filter(({ uri }) => !!uri)
.map(({ uri }) => {
const path = uri.path;
const title = path.replace(/.*\//i, "");
return {
title,
subtitle: path.replace("file://", ""),
arg: path,
};
});
} catch (error) {
alfy.log(error);
}
alfy.output(
alfy.inputMatches(emptyOutput, (item, input) => {
return item.title.includes(input);
})
);