File tree 2 files changed +50
-1
lines changed
2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,37 @@ interface INpmPeerDependencyInfo {
149
149
peerMissing : boolean ;
150
150
}
151
151
152
+ /**
153
+ * Describes information about dependency update packages.
154
+ */
155
+ interface INpmDependencyUpdateInfo {
156
+ /**
157
+ * Npm action type.
158
+ * @type {string }
159
+ */
160
+ action : string ;
161
+ /**
162
+ * Dependency name.
163
+ * @type {string }
164
+ */
165
+ name : string ;
166
+ /**
167
+ * Dependency version.
168
+ * @type {string }
169
+ */
170
+ version : string ;
171
+ /**
172
+ * Destination of the installation.
173
+ * @type {string }
174
+ */
175
+ path : string ;
176
+ /**
177
+ * Dependency previous version.
178
+ * @type {string }
179
+ */
180
+ previousVersion : string ;
181
+ }
182
+
152
183
/**
153
184
* Describes information returned by the npm CLI upon calling install with --json flag.
154
185
*/
@@ -168,7 +199,13 @@ interface INpmInstallCLIResult {
168
199
* Whenever installing npm prints the information by reversing the tree of operations and because the initial dependency was installed last it is listed first.
169
200
* @type {INpmDependencyInfo | INpmPeerDependencyInfo }
170
201
*/
171
- dependencies : INpmDependencyInfo | INpmPeerDependencyInfo ;
202
+ dependencies ?: INpmDependencyInfo | INpmPeerDependencyInfo ;
203
+
204
+ /**
205
+ * Updated dependencies. Note that whenever update a particular dependency with npm 5 it is listed inside of array with key "updated".
206
+ * @type {INpmDependencyUpdateInfo[] }
207
+ */
208
+ updated ?: INpmDependencyUpdateInfo [ ] ;
172
209
/**
173
210
* Describes problems that might have occurred during installation. For example missing peer dependencies.
174
211
*/
Original file line number Diff line number Diff line change @@ -145,6 +145,18 @@ export class NodePackageManager implements INodePackageManager {
145
145
try {
146
146
const originalOutput : INpmInstallCLIResult = JSON . parse ( npmDryRunInstallOutput ) ;
147
147
const name = _ . head ( _ . keys ( originalOutput . dependencies ) ) ;
148
+
149
+ // Npm 5 return different object after performing `npm install --dry-run`.
150
+ // Considering that the dependency is already installed we should
151
+ // find it in the `updated` key as a first element of the array.
152
+ if ( ! name && originalOutput . updated ) {
153
+ const updatedDependency = originalOutput . updated [ 0 ] ;
154
+ return {
155
+ name : updatedDependency . name ,
156
+ originalOutput,
157
+ version : updatedDependency . version
158
+ } ;
159
+ }
148
160
const dependency = _ . pick < INpmDependencyInfo , INpmDependencyInfo | INpmPeerDependencyInfo > ( originalOutput . dependencies , name ) ;
149
161
return {
150
162
name,
You can’t perform that action at this time.
0 commit comments