@npmcli/arborist
Advanced tools
Comparing version 0.0.20 to 0.0.21
@@ -8,2 +8,3 @@ // mixin implementing the buildIdealTree method | ||
const pickManifest = require('npm-pick-manifest') | ||
const mapWorkspaces = require('@npmcli/map-workspaces') | ||
const promiseCallLimit = require('promise-call-limit') | ||
@@ -56,2 +57,3 @@ const getPeerSet = require('../peer-set.js') | ||
const _manifests = Symbol('manifests') | ||
const _mapWorkspaces = Symbol('mapWorkspaces') | ||
const _linkFromSpec = Symbol('linkFromSpec') | ||
@@ -238,5 +240,8 @@ const _loadPeerSet = Symbol('loadPeerSet') | ||
// or else it'll get super confusing when we change them! | ||
// Only have to mapWorkspaces if we didn't get it from actual or virtual | ||
.then(async root => { | ||
if (!this[_updateAll] && !this[_global] && !root.meta.loadedFromDisk) | ||
await new this.constructor(this.options).loadActual({ root }) | ||
else if (!this[_global] && (!this[_usePackageLock] || this[_updateAll])) | ||
await this[_mapWorkspaces](root) | ||
return root | ||
@@ -279,2 +284,11 @@ }) | ||
[_mapWorkspaces] (node) { | ||
return mapWorkspaces({ cwd: node.path, pkg: node.package }) | ||
.then(workspaces => { | ||
if (workspaces.size) | ||
node.workspaces = workspaces | ||
return node | ||
}) | ||
} | ||
// process the add/rm requests by modifying the root node, and the | ||
@@ -281,0 +295,0 @@ // update.names request by queueing nodes dependent on those named. |
@@ -61,3 +61,3 @@ // mixin providing the loadVirtual method | ||
const { | ||
root = this[loadWorkspaces](await this[loadRoot](s), s), | ||
root = await this[loadRoot](s), | ||
} = options | ||
@@ -71,3 +71,3 @@ | ||
const pkg = await rpj(pj).catch(() => s.data.packages['']) || {} | ||
return this[loadNode]('', pkg) | ||
return this[loadWorkspaces](this[loadNode]('', pkg)) | ||
} | ||
@@ -136,2 +136,11 @@ | ||
const lockWS = [] | ||
const workspaces = mapWorkspaces.virtual({ | ||
cwd: this.path, | ||
lockfile: s.data, | ||
}) | ||
for (const [name, path] of workspaces.entries()) { | ||
lockWS.push(['workspace', name, `file:${path}`]) | ||
} | ||
const lockEdges = [ | ||
@@ -143,2 +152,3 @@ ...depsToEdges('prod', prod), | ||
...depsToEdges('peerOptional', peerOptional), | ||
...lockWS, | ||
].sort(([atype, aname], [btype, bname]) => | ||
@@ -270,6 +280,6 @@ atype.localeCompare(btype) || aname.localeCompare(bname)) | ||
[loadWorkspaces] (node, s) { | ||
const workspaces = mapWorkspaces.virtual({ | ||
async [loadWorkspaces] (node) { | ||
const workspaces = await mapWorkspaces({ | ||
cwd: node.path, | ||
lockfile: s.data, | ||
pkg: node.package, | ||
}) | ||
@@ -276,0 +286,0 @@ if (workspaces.size) |
@@ -300,3 +300,3 @@ // mixin implementing the reify method | ||
for (const node of this.idealTree.inventory.filter(filter)) { | ||
this[_trashList].add(node.path) | ||
this[_addNodeToTrashList](node) | ||
} | ||
@@ -303,0 +303,0 @@ process.emit('timeEnd', 'reify:trashOmits') |
{ | ||
"name": "@npmcli/arborist", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"description": "Manage node_modules trees", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
275180
6716