More version simplifiction. (#810)

This commit is contained in:
Tommaso Sciortino
2025-06-07 10:54:23 -07:00
committed by GitHub
parent 63757d6a7a
commit 680f4cdd61
8 changed files with 13 additions and 65 deletions

View File

@@ -4,31 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { readPackageUp } from 'read-package-up';
import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
let cliVersion: string | undefined;
export async function getCliVersion(): Promise<string> {
if (cliVersion) {
return cliVersion;
}
if (process.env.CLI_VERSION) {
cliVersion = process.env.CLI_VERSION;
return cliVersion;
}
try {
const readUpResult = await readPackageUp({ cwd: __dirname });
cliVersion = readUpResult?.packageJson.version || 'unknown';
} catch (_e) {
cliVersion = 'unknown';
}
return cliVersion;
export function getCliVersion(): string {
return process.env.CLI_VERSION || process.version;
}