Browse Source

Refactor generate-svg.js (#29348)

Small refactor to avoid `process` global and to sync it with
`generate-images`.
tags/v1.22.0-rc0
silverwind 3 months ago
parent
commit
08c1926e1c
No account linked to committer's email address
1 changed files with 5 additions and 4 deletions
  1. 5
    4
      build/generate-svg.js

+ 5
- 4
build/generate-svg.js View File

import {parse} from 'node:path'; import {parse} from 'node:path';
import {readFile, writeFile, mkdir} from 'node:fs/promises'; import {readFile, writeFile, mkdir} from 'node:fs/promises';
import {fileURLToPath} from 'node:url'; import {fileURLToPath} from 'node:url';
import {exit} from 'node:process';


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


function exit(err) {
function doExit(err) {
if (err) console.error(err); if (err) console.error(err);
process.exit(err ? 1 : 0);
exit(err ? 1 : 0);
} }


async function processFile(file, {prefix, fullName} = {}) { async function processFile(file, {prefix, fullName} = {}) {
} }


try { try {
exit(await main());
doExit(await main());
} catch (err) { } catch (err) {
exit(err);
doExit(err);
} }

Loading…
Cancel
Save