diff --git a/lib/xpm/install.js b/lib/xpm/install.js index 079bb98..c65e448 100644 --- a/lib/xpm/install.js +++ b/lib/xpm/install.js @@ -901,14 +901,6 @@ export class Install extends CliCommand { const dependencyDestination = this.computeDependencyDestination(defaultDestination) if (dependencyDestination) { - if (configurationName) { - log.verbose(`Adding '${manifestIds.getScopedName()}' to ` + - `'${configurationName}/${dependencyDestination}'...`) - } else { - log.verbose(`Adding '${manifestIds.getScopedName()}' to ` + - `'${dependencyDestination}'...`) - } - const depName = manifestIds.getScopedName() const depValueString = this.computeDependencyValue({ manifest }) @@ -948,6 +940,32 @@ export class Install extends CliCommand { } } + ['dependencies', 'devDependencies', 'optionalDependencies'].forEach( + (dependency) => { + if (Object.prototype.hasOwnProperty.call( + target, dependency)) { + if (Object.prototype.hasOwnProperty.call( + target[dependency], depName)) { + if (configurationName) { + log.verbose(`Removing '${depName}' from ` + + `'${configurationName}/${dependency}'`) + } else { + log.verbose(`Removing '${depName}' from ` + + `'${dependency}'`) + } + delete target[dependency][depName] + } + } + }) + + if (configurationName) { + log.verbose(`Adding '${manifestIds.getScopedName()}' to ` + + `'${configurationName}/${dependencyDestination}'...`) + } else { + log.verbose(`Adding '${manifestIds.getScopedName()}' to ` + + `'${dependencyDestination}'...`) + } + // If the destination object is not yet there, create an empty one. if (!Object.prototype.hasOwnProperty.call( target, dependencyDestination)) {