mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
fix: 修复版本号获取错误的bug
This commit is contained in:
@@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user