source: trip-planner-front/node_modules/@schematics/angular/utility/dependencies.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.2 KB
Line 
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.getPackageJsonDependency = exports.removePackageJsonDependency = exports.addPackageJsonDependency = exports.NodeDependencyType = void 0;
11const json_file_1 = require("./json-file");
12const PKG_JSON_PATH = '/package.json';
13var NodeDependencyType;
14(function (NodeDependencyType) {
15 NodeDependencyType["Default"] = "dependencies";
16 NodeDependencyType["Dev"] = "devDependencies";
17 NodeDependencyType["Peer"] = "peerDependencies";
18 NodeDependencyType["Optional"] = "optionalDependencies";
19})(NodeDependencyType = exports.NodeDependencyType || (exports.NodeDependencyType = {}));
20const ALL_DEPENDENCY_TYPE = [
21 NodeDependencyType.Default,
22 NodeDependencyType.Dev,
23 NodeDependencyType.Optional,
24 NodeDependencyType.Peer,
25];
26function addPackageJsonDependency(tree, dependency, pkgJsonPath = PKG_JSON_PATH) {
27 const json = new json_file_1.JSONFile(tree, pkgJsonPath);
28 const { overwrite, type, name, version } = dependency;
29 const path = [type, name];
30 if (overwrite || !json.get(path)) {
31 json.modify(path, version);
32 }
33}
34exports.addPackageJsonDependency = addPackageJsonDependency;
35function removePackageJsonDependency(tree, name, pkgJsonPath = PKG_JSON_PATH) {
36 const json = new json_file_1.JSONFile(tree, pkgJsonPath);
37 for (const depType of ALL_DEPENDENCY_TYPE) {
38 json.remove([depType, name]);
39 }
40}
41exports.removePackageJsonDependency = removePackageJsonDependency;
42function getPackageJsonDependency(tree, name, pkgJsonPath = PKG_JSON_PATH) {
43 const json = new json_file_1.JSONFile(tree, pkgJsonPath);
44 for (const depType of ALL_DEPENDENCY_TYPE) {
45 const version = json.get([depType, name]);
46 if (typeof version === 'string') {
47 return {
48 type: depType,
49 name: name,
50 version,
51 };
52 }
53 }
54 return null;
55}
56exports.getPackageJsonDependency = getPackageJsonDependency;
Note: See TracBrowser for help on using the repository browser.