mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-21 08:31:27 -05:00
Refactor generate-svg.js (#29348)
Small refactor to avoid `process` global and to sync it with `generate-images`. (cherry picked from commit 08c1926e1c3e2487f207b5f225d8b0f2831d0708)
This commit is contained in:
parent
7db422d989
commit
7143f8fcdd
1 changed files with 5 additions and 4 deletions
|
@ -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} = {}) {
|
||||
|
@ -63,7 +64,7 @@ async function main() {
|
|||
}
|
||||
|
||||
try {
|
||||
exit(await main());
|
||||
doExit(await main());
|
||||
} catch (err) {
|
||||
exit(err);
|
||||
doExit(err);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue