1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
|
4 |
|
5 |
|
6 | function addPackageToPackageJson(host, type, pkg, version) {
|
7 | if (host.exists('package.json')) {
|
8 | const sourceText = host.read('package.json').toString('utf-8');
|
9 | const json = JSON.parse(sourceText);
|
10 | if (!json[type]) {
|
11 | json[type] = {};
|
12 | }
|
13 | if (!json[type][pkg]) {
|
14 | json[type][pkg] = version;
|
15 | }
|
16 | host.overwrite('package.json', JSON.stringify(json, null, 2));
|
17 | }
|
18 | return host;
|
19 | }
|
20 | exports.addPackageToPackageJson = addPackageToPackageJson;
|