This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
feat: npm workspaces #50
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// mixin providing the loadVirtual method | ||
|
||
const {resolve} = require('path') | ||
const mapWorkspaces = require('@npmcli/map-workspaces') | ||
|
||
const consistentResolve = require('../consistent-resolve.js') | ||
const Shrinkwrap = require('../shrinkwrap.js') | ||
|
@@ -15,6 +16,7 @@ const resolveLinks = Symbol('resolveLinks') | |
const assignParentage = Symbol('assignParentage') | ||
const loadNode = Symbol('loadVirtualNode') | ||
const loadLink = Symbol('loadVirtualLink') | ||
const loadWorkspaces = Symbol('loadWorkspaces') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just noticing this now, not relevant to this PR, but we should make loadVirtual underscore its symbols like the other mixin classes. |
||
|
||
module.exports = cls => class VirtualLoader extends cls { | ||
constructor (options) { | ||
|
@@ -39,7 +41,10 @@ module.exports = cls => class VirtualLoader extends cls { | |
// when building the ideal tree, we pass in a root node to this function | ||
// otherwise, load it from the root package in the lockfile | ||
const { | ||
root = this[loadNode]('', s.data.packages[''] || {}) | ||
root = this[loadWorkspaces]( | ||
this[loadNode]('', s.data.packages[''] || {}), | ||
s | ||
) | ||
} = options | ||
|
||
return this[loadFromShrinkwrap](s, root) | ||
|
@@ -160,6 +165,16 @@ module.exports = cls => class VirtualLoader extends cls { | |
return node | ||
} | ||
|
||
[loadWorkspaces] (node, s) { | ||
const workspaces = mapWorkspaces.virtual({ | ||
cwd: node.path, | ||
lockfile: s.data | ||
}) | ||
if (workspaces.size) | ||
node.workspaces = workspaces | ||
return node | ||
} | ||
|
||
[loadLink] (location, targetLoc, target, meta) { | ||
const path = resolve(this.path, location) | ||
const link = new Link({ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see where this field is used, is it a leftover from something that changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah def a leftover, will clean it up 😊