Skip to content

Commit

Permalink
#194: remove possible entries in dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ilg-ul committed Feb 27, 2024
1 parent 6974c72 commit 28273b6
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions lib/xpm/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })

Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 28273b6

Please sign in to comment.