1 | import { resolve as resolvePath } from 'path';
|
2 |
|
3 | const packageJsonPath = resolvePath(
|
4 | __dirname,
|
5 | '../package'
|
6 | );
|
7 |
|
8 | export 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 |
|
18 | export type Field = 'version' | 'name'; |
\ | No newline at end of file |