forked from Yuki-zik/taskvision
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildCodiconNames.js
More file actions
executable file
·48 lines (39 loc) · 1.74 KB
/
buildCodiconNames.js
File metadata and controls
executable file
·48 lines (39 loc) · 1.74 KB
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
const fs = require('fs');
const https = require('https');
const path = require('path');
const url = 'https://raw.githubusercontent.com/microsoft/vscode-codicons/main/src/template/mapping.json';
const outputFile = path.join(__dirname, 'src', 'codiconNames.js');
console.log(`Fetching codicon mapping from ${url}...`);
https.get(url, (res) => {
let data = '';
if (res.statusCode !== 200) {
console.error(`Failed to fetch codicons: Status Code ${res.statusCode}`);
// Fallback or exit? For now, let's just create a minimal valid file to allow build to pass
writeMinimalFile();
return;
}
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
try {
const mapping = JSON.parse(data);
const keys = Object.keys(mapping);
const fileContent = `module.exports = ${JSON.stringify(keys, null, 4)};\n`;
fs.writeFileSync(outputFile, fileContent);
console.log(`Successfully wrote ${keys.length} codicon names to ${outputFile}`);
} catch (e) {
console.error('Error parsing JSON:', e.message);
writeMinimalFile();
}
});
}).on('error', (err) => {
console.error('Error fetching codicons:', err.message);
writeMinimalFile();
});
function writeMinimalFile() {
console.log('Writing minimal codiconNames.js due to fetch failure.');
// Write a minimal valid file so the extension can still build
const minimalContent = "module.exports = ['add', 'alert', 'check', 'close', 'edit', 'gear', 'info', 'issue-opened', 'issue-closed', 'list-tree', 'lock', 'pass', 'play', 'refresh', 'search', 'trash', 'warning', 'workspace-trusted'];\n";
fs.writeFileSync(outputFile, minimalContent);
}