Skip to content

Commit 66c21c2

Browse files
dnadobarosen-vladimirov
authored andcommitted
find the correct dependency by searching for the userSpecifiedPackageName (#3213)
1 parent d4817bc commit 66c21c2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/node-package-manager.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,12 @@ export class NodePackageManager implements INodePackageManager {
156156
});
157157

158158
// Npm 5 return different object after performing `npm install --dry-run`.
159-
// Considering that the dependency is already installed we should
160-
// find it in the `updated` key as a first element of the array.
159+
// We find the correct dependency by searching for the `userSpecifiedPackageName` in the
160+
// `npm5Output.updated` array and as a fallback, considering that the dependency is already installed,
161+
// we find it as the first element.
161162
if (!name && npm5Output.updated) {
162-
const updatedDependency = npm5Output.updated[0];
163+
const packageNameWithoutVersion = userSpecifiedPackageName.split('@')[0];
164+
const updatedDependency = _.find(npm5Output.updated, ['name', packageNameWithoutVersion]) || npm5Output.updated[0];
163165
return {
164166
name: updatedDependency.name,
165167
originalOutput,

0 commit comments

Comments
 (0)