Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions workspaces/arborist/lib/arborist/isolated-reifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { join } = require('node:path')
const { depth } = require('treeverse')
const crypto = require('node:crypto')
const { IsolatedNode, IsolatedLink } = require('../isolated-classes.js')
const nameFromFolder = require('@npmcli/name-from-folder')

// generate short hash key based on the dependency tree starting at this node
const getKey = (startNode) => {
Expand Down Expand Up @@ -149,7 +150,7 @@ module.exports = cls => class IsolatedReifier extends cls {
node.root.path,
'node_modules',
'.store',
`${node.packageName}@${node.version}`
`${result.packageName}@${node.version}`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I think this was the last bit of update we were missing. The common properties assignment function handles the cleaning and now we can trust result.packageName.

👍

)
mkdirSync(dir, { recursive: true })
// TODO this approach feels wrong and shouldn't be necessary for shrinkwraps
Expand Down Expand Up @@ -191,7 +192,7 @@ module.exports = cls => class IsolatedReifier extends cls {
result.id = this.counter++
/* istanbul ignore next - packageName is always set for real packages */
result.name = result.isWorkspace ? (node.packageName || node.name) : node.name
result.packageName = node.packageName || node.name
result.packageName = nameFromFolder(node.packageName || node.path)
result.package = { ...node.package }
result.package.bundleDependencies = undefined

Expand Down
5 changes: 5 additions & 0 deletions workspaces/arborist/lib/isolated-classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ class IsolatedNode {
return !!(hasInstallScript || install || preinstall || postinstall)
}

/* istanbul ignore next -- emulate lib/node.js */
get packageName () {
return this.package.name || null
}

get version () {
return this.package.version
}
Expand Down