mirror of
https://github.com/EvoMap/evolver.git
synced 2026-09-18 21:47:53 +08:00
16 lines
713 B
JavaScript
16 lines
713 B
JavaScript
import { dirname } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { util } from '@evomap/evolver-core';
|
|
function isEvolverCliPackage(pkg) {
|
|
return pkg.name === '@evomap/evolver-cli'
|
|
|| (typeof pkg.bin === 'object' && typeof pkg.bin['evolver'] === 'string');
|
|
}
|
|
/** Resolve the installed evolver CLI version from the nearest package metadata. */
|
|
export function getCliVersion() {
|
|
const buildVersion = process.env.EVOLVER_CLI_VERSION?.trim();
|
|
return util.resolveRuntimeVersion({
|
|
startDir: dirname(fileURLToPath(import.meta.url)),
|
|
isPackage: isEvolverCliPackage,
|
|
...(buildVersion && buildVersion !== '0.0.0' ? { fallback: buildVersion } : {}),
|
|
});
|
|
} |