MCPcopy Create free account
hub / github.com/npm/cli / replace

Method replace

workspaces/arborist/lib/node.js:1217–1251  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

1215 }
1216
1217 replace (node) {
1218 this[_delistFromMeta]()
1219
1220 // if the name matches, but is not identical, we are intending to clobber
1221 // something case-insensitively, so merely setting name and path won't
1222 // have the desired effect. just set the path so it'll collide in the
1223 // parent's children map, and leave it at that.
1224 if (node.parent?.children.get(this.name) === node) {
1225 this.path = resolve(node.parent.path, 'node_modules', this.name)
1226 } else {
1227 this.path = node.path
1228 this.name = node.name
1229 }
1230
1231 if (!this.isLink) {
1232 this.realpath = this.path
1233 }
1234 this[_refreshLocation]()
1235
1236 // keep children when a node replaces another
1237 if (!this.isLink) {
1238 for (const kid of node.children.values()) {
1239 kid.parent = this
1240 }
1241 if (node.isLink && node.target) {
1242 node.target.root = null
1243 }
1244 }
1245
1246 if (!node.isRoot) {
1247 this.root = node.root
1248 }
1249
1250 treeCheck(this)
1251 }
1252
1253 get inShrinkwrap () {
1254 return this.parent &&

Callers 15

runTestFunction · 0.95
normalizePathFunction · 0.80
getCleanPathsFunction · 0.80
cleanOutputFunction · 0.80
NpmClass · 0.80
hostedFromManiMethod · 0.80
toSpdxIDFunction · 0.80
readOTPFunction · 0.80
#cleanLogsMethod · 0.80
writeMethod · 0.80
logTitleMethod · 0.80
derefFunction · 0.80

Calls 2

resolveFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected