-
Notifications
You must be signed in to change notification settings - Fork 8
/
compile.js
45 lines (41 loc) · 1.36 KB
/
compile.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
const os = require('os');
const fs = require('fs');
const exec = require('child_process').exec;
const destDir = `${os.homedir()}/aws-launcher`;
urlsFixing = {
"Lightsail": "https://lightsail.aws.amazon.com/ls/webapp/create/instance",
"QuickSight": "https://us-east-1.quicksight.aws.amazon.com/sn/console"
}
namespacesFixing = {
"CertificateManager": "acm",
"ElasticCache": "elasticache",
"EMR": "elasticmapreduce",
"Shield": "waf",
"Snowball": "importexport",
"StepFunctions": "states",
"WorkDocs": "zocalo",
"X-Ray": "xray",
}
// Create destination folder
if (!fs.existsSync(destDir)) {
fs.mkdirSync(destDir);
}
// Create shortcuts
files = fs.readdirSync('icons');
files.forEach((file, index) => {
file = file.replace(/\.[^/.]+$/, "");
console.log(`Compiling ${file}`);
const namespace = namespacesFixing[file] || file.toLowerCase();
const url = urlsFixing[file] || `https://console.aws.amazon.com/${namespace}/home`;
fs.writeFileSync(`${destDir}/${file}.url`, `[InternetShortcut]\nURL=${url}`);
exec(`fileicon set ${destDir}/${file}.url icons/${file}.png`, function(error, stdout, stderr) {
console.log(error || stdout);
if (!error) {
exec(`SetFile -a E ${destDir}/${file}.url`, function(error, stdout, stderr) {
if (!error && index === files.length - 1) {
exec(`open ${destDir}`);
}
});
}
});
})