chore: don't fail the build when building from source tarball (#40)

This commit is contained in:
鲁树人
2023-09-16 15:11:11 +01:00
parent e003eba10c
commit 1c3b43c419
3 changed files with 22 additions and 10 deletions

17
support/command.ts Normal file
View File

@@ -0,0 +1,17 @@
import cp from 'node:child_process';
import path from 'node:path';
import url from 'node:url';
const projectRoot = url.fileURLToPath(new URL('../', import.meta.url));
export function command(cmd: string, dir = '') {
return cp.execSync(cmd, { cwd: path.join(projectRoot, dir), encoding: 'utf-8' }).trim();
}
export function tryCommand(cmd: string, dir = '', fallback = '') {
try {
return command(cmd, dir);
} catch (e) {
return fallback;
}
}