From 08c1926e1c3e2487f207b5f225d8b0f2831d0708 Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 23 Feb 2024 23:07:27 +0100 Subject: [PATCH] Refactor generate-svg.js (#29348) Small refactor to avoid `process` global and to sync it with `generate-images`. --- build/generate-svg.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/build/generate-svg.js b/build/generate-svg.js index 2c0a5e37b..f26b60d96 100755 --- a/build/generate-svg.js +++ b/build/generate-svg.js @@ -4,15 +4,16 @@ import {optimize} from 'svgo'; import {parse} from 'node:path'; import {readFile, writeFile, mkdir} from 'node:fs/promises'; import {fileURLToPath} from 'node:url'; +import {exit} from 'node:process'; const glob = (pattern) => fastGlob.sync(pattern, { cwd: fileURLToPath(new URL('..', import.meta.url)), absolute: true, }); -function exit(err) { +function doExit(err) { if (err) console.error(err); - process.exit(err ? 1 : 0); + exit(err ? 1 : 0); } async function processFile(file, {prefix, fullName} = {}) { @@ -64,7 +65,7 @@ async function main() { } try { - exit(await main()); + doExit(await main()); } catch (err) { - exit(err); + doExit(err); }