Skip to content

Commit 08c1926

Browse files
authored
Refactor generate-svg.js (#29348)
Small refactor to avoid `process` global and to sync it with `generate-images`.
1 parent 53c7d89 commit 08c1926

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

build/generate-svg.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ import {optimize} from 'svgo';
44
import {parse} from 'node:path';
55
import {readFile, writeFile, mkdir} from 'node:fs/promises';
66
import {fileURLToPath} from 'node:url';
7+
import {exit} from 'node:process';
78

89
const glob = (pattern) => fastGlob.sync(pattern, {
910
cwd: fileURLToPath(new URL('..', import.meta.url)),
1011
absolute: true,
1112
});
1213

13-
function exit(err) {
14+
function doExit(err) {
1415
if (err) console.error(err);
15-
process.exit(err ? 1 : 0);
16+
exit(err ? 1 : 0);
1617
}
1718

1819
async function processFile(file, {prefix, fullName} = {}) {
@@ -64,7 +65,7 @@ async function main() {
6465
}
6566

6667
try {
67-
exit(await main());
68+
doExit(await main());
6869
} catch (err) {
69-
exit(err);
70+
doExit(err);
7071
}

0 commit comments

Comments
 (0)