UNPKG

1.37 kBJavaScriptView Raw
1"use strict";
2var __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};
10Object.defineProperty(exports, "__esModule", { value: true });
11const path_1 = require("path");
12const vamtiger_get_file_text_1 = require("vamtiger-get-file-text");
13const { cwd } = process;
14const { parse } = JSON;
15const packageJsonPath = path_1.resolve(cwd(), 'package.json');
16function 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}
28exports.default = default_1;
29//# sourceMappingURL=get-package-data.js.map
\No newline at end of file