UNPKG

@emigrate/cli

Version:

Emigrate is a tool for managing database migrations. It is designed to be simple yet support advanced setups, modular and extensible.

24 lines 900 B
import fs from 'node:fs/promises'; import { fileURLToPath } from 'node:url'; import { UnexpectedError } from './errors.js'; const getPackageInfo = async () => { const packageInfoPath = fileURLToPath(new URL('../package.json', import.meta.url)); try { const content = await fs.readFile(packageInfoPath, 'utf8'); const packageJson = JSON.parse(content); if (typeof packageJson === 'object' && packageJson && 'version' in packageJson && typeof packageJson.version === 'string') { return packageJson; } } catch { // ignore } throw new UnexpectedError(`Could not read package info from: ${packageInfoPath}`); }; const packageInfo = await getPackageInfo(); // eslint-disable-next-line prefer-destructuring export const version = packageInfo.version; //# sourceMappingURL=get-package-info.js.map