Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 23x 5x 5x 5x 5x 15x | import { readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
let cachedVersion: string | undefined;
export function getVersion(): string {
if (cachedVersion) return cachedVersion;
const __dirname = dirname(fileURLToPath(import.meta.url));
const pkg = JSON.parse(readFileSync(join(__dirname, '..', '..', 'package.json'), 'utf-8')) as { version: string };
cachedVersion = pkg.version;
return cachedVersion;
}
export function getMajorVersion(): string {
return getVersion().split('.')[0] ?? '0';
}
|