Used to add multiple packages to the project's `package.json`. Generally, this would be done from the `afterInstall` hook, to ensure that a package that is required by a given blueprint is available. Expects each array item to be an object with a `name`. Each object may option
(packages)
| 1101 | ``` |
| 1102 | */ |
| 1103 | addPackagesToProject(packages) { |
| 1104 | let task = this.taskFor('npm-install'); |
| 1105 | let installText = packages.length > 1 ? 'install packages' : 'install package'; |
| 1106 | let packageNames = []; |
| 1107 | let packageArray = []; |
| 1108 | |
| 1109 | for (let i = 0; i < packages.length; i++) { |
| 1110 | packageNames.push(packages[i].name); |
| 1111 | |
| 1112 | let packageNameAndVersion = packages[i].name; |
| 1113 | |
| 1114 | if (packages[i].target) { |
| 1115 | packageNameAndVersion += `@${packages[i].target}`; |
| 1116 | } |
| 1117 | |
| 1118 | packageArray.push(packageNameAndVersion); |
| 1119 | } |
| 1120 | |
| 1121 | this._writeStatusToUI(chalk.green, installText, packageNames.join(', ')); |
| 1122 | |
| 1123 | return task.run({ |
| 1124 | 'save-dev': true, |
| 1125 | verbose: false, |
| 1126 | packages: packageArray, |
| 1127 | }); |
| 1128 | }, |
| 1129 | |
| 1130 | /** |
| 1131 | Used to remove a package from the project's `package.json`. |
nothing calls this directly
no test coverage detected
searching dependent graphs…