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.
deps: Stop overzealously replacing subdeps when updating
- Loading branch information
Showing
3 changed files
with
47 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict' | ||
var test = require('tap').test | ||
var requireInject = require('require-inject') | ||
|
||
// we're just mocking to avoid having to call `npm.load` | ||
var deps = requireInject('../../lib/install/deps.js', { | ||
'../../lib/npm.js': { | ||
config: { | ||
get: function () { return 'mock' } | ||
} | ||
} | ||
}) | ||
|
||
var removeObsoleteDep = deps._removeObsoleteDep | ||
|
||
test('removeObsoleteDep', function (t) { | ||
var child1 = {requiredBy: []} | ||
var test1 = { | ||
removed: true, | ||
requires: [ child1 ] | ||
} | ||
removeObsoleteDep(test1) | ||
t.is(child1.removed, undefined, 'no recursion on deps flagged as removed already') | ||
|
||
var child2 = {requiredBy: []} | ||
var test2 = { | ||
requires: [ child2 ] | ||
} | ||
child2.requiredBy.push(test2) | ||
removeObsoleteDep(test2) | ||
t.is(child2.removed, true, 'required by no other modules, removing') | ||
|
||
var child3 = {requiredBy: ['NOTEMPTY']} | ||
var test3 = { | ||
requires: [ child3 ] | ||
} | ||
child3.requiredBy.push(test3) | ||
removeObsoleteDep(test3) | ||
t.is(child3.removed, undefined, 'required by other modules, keeping') | ||
t.done() | ||
}) |
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