This repository has been archived by the owner on Aug 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
diff-trees: Make install order more consistent for directly dependencies
The install order is determined by: 1) The location of the thing to be installed relative to the root module. 2) Dependency order, such that a -> b -> c will install modules as: c, b, a 1 is deterministic, regardless of what's being installed. But 2 can change the order of things higher in the dep tree. Eg, b, or a might get sorted earlier if c requires them. This mostly doesn't matter, but it does mean that if you have two modules with conflicting bins, they _can_ get installed in different orders. This changes sorts all of the top level modules to be LAST, in location order (1), and then sorts all the rest per (2). This ensures that top level modules have a deterministic install order. (Non top level modules can't have bin conflicts as that's treated the same as a version conflict and the conflicting module would be hoisted.) PR-URL: #9274 Fixes: #8995
- Loading branch information
Showing
3 changed files
with
65 additions
and
8 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict' | ||
var test = require('tap').test | ||
var sortActions = require('../../lib/install/diff-trees.js').sortActions | ||
|
||
var a = { | ||
package: {_location: '/a', _requiredBy: []} | ||
} | ||
var b = { | ||
package: {_location: '/b', _requiredBy: []} | ||
} | ||
var c = { | ||
package: {_location: '/c', _requiredBy: ['/a', '/b']} | ||
} | ||
|
||
test('install-order when installing deps', function (t) { | ||
var plain = [ | ||
['add', a], | ||
['add', b], | ||
['add', c]] | ||
var sorted = [ | ||
['add', c], | ||
['add', a], | ||
['add', b]] | ||
t.isDeeply(sortActions(plain), sorted) | ||
t.end() | ||
}) | ||
|
||
test('install-order when not installing deps', function (t) { | ||
var plain = [ | ||
['add', a], | ||
['add', b]] | ||
var sorted = [ | ||
['add', a], | ||
['add', b]] | ||
t.isDeeply(sortActions(plain), sorted) | ||
t.end() | ||
}) |