Skip to content

Commit e6c9fff

Browse files
committed
Converts icons script to esm
Attempts to improve perf will better parallel i/o
1 parent f57d064 commit e6c9fff

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

.fantasticonrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ts-check
22

3-
/** @type { import('@twbs/fantasticon').RunnerOptions} } */
3+
/** @type {import('@twbs/fantasticon').RunnerOptions} */
44
const config = {
55
name: 'glicons',
66
prefix: 'glicon',

scripts/applyIconsContribution.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

scripts/applyIconsContribution.mjs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import fs from 'fs';
2+
3+
const packageJSONPromises = Promise.all([
4+
import('../package.json', { assert: { type: 'json' } }),
5+
import('../dist/icons-contribution.json', { assert: { type: 'json' } }),
6+
]);
7+
8+
const scssPromises = Promise.all([
9+
fs.promises.readFile('./dist/glicons.scss', 'utf8'),
10+
fs.promises.readFile('./src/webviews/apps/shared/glicons.scss', 'utf8'),
11+
]);
12+
13+
let pending = [];
14+
15+
// Update the icons contribution point in package.json
16+
const [{ default: packageJSON }, { default: icons }] = await packageJSONPromises;
17+
18+
if (JSON.stringify(packageJSON.contributes.icons) !== JSON.stringify(icons.icons)) {
19+
packageJSON.contributes.icons = icons;
20+
const json = `${JSON.stringify(packageJSON, undefined, '\t')}\n`;
21+
pending.push(fs.promises.writeFile('./package.json', json));
22+
}
23+
24+
// Update the scss file
25+
const [newScss, scss] = await scssPromises;
26+
27+
if (scss !== newScss) {
28+
pending.push(fs.promises.writeFile('./src/webviews/apps/shared/glicons.scss', newScss));
29+
}
30+
31+
pending.push(fs.promises.rm('./dist/icons-contribution.json'), fs.promises.rm('./dist/glicons.scss'));
32+
await Promise.allSettled(pending);

0 commit comments

Comments
 (0)