UNPKG

416 BPlain TextView Raw
1import { resolve as resolvePath } from 'path';
2
3const packageJsonPath = resolvePath(
4 __dirname,
5 '../package'
6);
7
8export default function (field: Field) {
9 const packageJson = require(packageJsonPath);
10
11 if (field === 'version') {
12 return packageJson.version as string;
13 } else if (field === 'name') {
14 return packageJson.name as string;
15 }
16}
17
18export type Field = 'version' | 'name';
\No newline at end of file