fix: 修复版本号获取错误的bug

pull/213/head
xiaojunnuo 2024-10-14 13:30:50 +08:00
parent 94fca0b554
commit 8851870400
1 changed files with 9 additions and 3 deletions

View File

@ -1,7 +1,13 @@
import { logger } from '@certd/pipeline';
import fs from 'fs';
export async function getVersion() {
const pkg = await fs.promises.readFile('../../../package.json');
const pkgJson = JSON.parse(pkg.toString());
return pkgJson.version;
try {
const pkg = await fs.promises.readFile('./package.json');
const pkgJson = JSON.parse(pkg.toString());
return pkgJson.version;
} catch (e) {
logger.error(e);
return 'unknown';
}
}