Skip to content

PromptScript API


Function: getPackageVersion()

getPackageVersion(baseDir, relativePath): string

Defined in: core/src/utils/package.ts:63

Get package version from a package.json file.

Parameters

baseDir

string

Base directory containing package.json (typically __dirname of the caller)

relativePath

string = '../package.json'

Relative path to package.json from baseDir (default: '../package.json')

Returns

string

Package version string

Example

// In src/cli.ts
const version = getPackageVersion(__dirname);
console.log(version); // "1.0.0"