-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwin32.js
60 lines (48 loc) · 1.49 KB
/
win32.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const fse = require("fs-extra");
const _ = require("lodash");
const arvish = require("arvish");
const path = require("path");
const os = require("os");
const fg = require("fast-glob");
// const { extractIcon } = require("@bitdisaster/exe-icon-extractor");
const conf = require("./conf");
const sep = path.sep;
const getIcon = (appName) => {
if (arvish.config.has('cachingComplete')) {
return `${appName}.app.png`;
}
return "icon.png";
};
const cacheIcon = async () => {
try {
if (!(await fse.pathExists(`${arvish.env.cache}/icons`))) {
await fse.mkdir(`${arvish.env.cache}/icons`);
}
const globOpts = {
absolute: true,
caseSensitiveMatch: false,
concurrency: conf.concurrency ? conf.concurrency : os.cpus().length,
deep: process.platform === "darwin" ? 1 : conf.deep,
dot: false,
onlyFiles: true,
};
const appPaths = [];
const targetPath =
`${conf.applicationFolders["win32"][0]}${sep}**${sep}*.lnk`
.split("\\")
.join("/");
fg(targetPath, globOpts)
.then((lnkPaths) => {
})
.catch(console.error);
// appPaths.map(async appPath => {
// const fileName = appPath.split(path.sep).pop();
// const buf = extractIcon(appPath, "large");
// await fse.writeFile(`${arvish.env.cache}/icons/${fileName}.png`, buf);
// });
arvish.config.set("cachingComplete", true);
} catch (err) {
console.log("Error occured", err);
}
};
module.exports = { getIcon, cacheIcon };