1 | "use strict";
|
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 | return new (P || (P = Promise))(function (resolve, reject) {
|
4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
7 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8 | });
|
9 | };
|
10 | Object.defineProperty(exports, "__esModule", { value: true });
|
11 | const path_1 = require("path");
|
12 | const vamtiger_get_file_text_1 = require("vamtiger-get-file-text");
|
13 | const { cwd } = process;
|
14 | const { parse } = JSON;
|
15 | const packageJsonPath = path_1.resolve(cwd(), 'package.json');
|
16 | function default_1(field) {
|
17 | return __awaiter(this, void 0, void 0, function* () {
|
18 | const packageJsonText = yield vamtiger_get_file_text_1.default(packageJsonPath);
|
19 | const packageJson = parse(packageJsonText);
|
20 | if (field === 'version') {
|
21 | return packageJson.version;
|
22 | }
|
23 | else if (field === 'name') {
|
24 | return packageJson.name;
|
25 | }
|
26 | });
|
27 | }
|
28 | exports.default = default_1;
|
29 |
|
\ | No newline at end of file |