From 251864897e262afa39df3c0c44f77fe2b6939c2c Mon Sep 17 00:00:00 2001 From: David Nadoba Date: Fri, 10 Nov 2017 18:13:11 +0100 Subject: [PATCH] find the correct dependency by searching for the `userSpecifiedPackageName` --- lib/node-package-manager.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/node-package-manager.ts b/lib/node-package-manager.ts index 60ca9c9d54..77bb61e056 100644 --- a/lib/node-package-manager.ts +++ b/lib/node-package-manager.ts @@ -156,10 +156,12 @@ export class NodePackageManager implements INodePackageManager { }); // Npm 5 return different object after performing `npm install --dry-run`. - // Considering that the dependency is already installed we should - // find it in the `updated` key as a first element of the array. + // We find the correct dependency by searching for the `userSpecifiedPackageName` in the + // `npm5Output.updated` array and as a fallback, considering that the dependency is already installed, + // we find it as the first element. if (!name && npm5Output.updated) { - const updatedDependency = npm5Output.updated[0]; + const packageNameWithoutVersion = userSpecifiedPackageName.split('@')[0]; + const updatedDependency = _.find(npm5Output.updated, ['name', packageNameWithoutVersion]) || npm5Output.updated[0]; return { name: updatedDependency.name, originalOutput,