1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.addPackageToPackageJson = void 0;
|
4 |
|
5 |
|
6 |
|
7 | function addPackageToPackageJson(host, type, pkg, version) {
|
8 | var _a, _b;
|
9 | if (host.exists('package.json')) {
|
10 | var sourceText = (_b = (_a = host.read('package.json')) === null || _a === void 0 ? void 0 : _a.toString('utf-8')) !== null && _b !== void 0 ? _b : '{}';
|
11 | var json = JSON.parse(sourceText);
|
12 | if (!json[type]) {
|
13 | json[type] = {};
|
14 | }
|
15 | if (!json[type][pkg]) {
|
16 | json[type][pkg] = version;
|
17 | }
|
18 | host.overwrite('package.json', JSON.stringify(json, null, 2));
|
19 | }
|
20 | return host;
|
21 | }
|
22 | exports.addPackageToPackageJson = addPackageToPackageJson;
|
23 |
|
\ | No newline at end of file |