Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

read-installed@2.0.1

  • Loading branch information...
commit f6712869ee0f3f2cfa705aa626ae374213ef0fef 1 parent d4c5d27
@isaacs isaacs authored
View
4 node_modules/read-installed/package.json
@@ -1,7 +1,7 @@
{
"name": "read-installed",
"description": "Read all the installed packages in a folder, and return a tree structure with all the data.",
- "version": "2.0.0",
+ "version": "2.0.1",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/read-installed"
@@ -35,6 +35,6 @@
"url": "https://github.com/isaacs/read-installed/issues"
},
"homepage": "https://github.com/isaacs/read-installed",
- "_id": "read-installed@2.0.0",
+ "_id": "read-installed@2.0.1",
"_from": "read-installed@latest"
}
View
27 node_modules/read-installed/read-installed.js
@@ -126,6 +126,7 @@ function readInstalled (folder, opts, cb) {
// now obj has all the installed things, where they're installed
// figure out the inheritance links, now that the object is built.
resolveInheritance(obj, opts)
+ markExtraneous(obj)
cb(null, obj)
})
}
@@ -312,8 +313,6 @@ function findUnmet (obj, opts) {
+found.path+",\nwhich is version "+found.version
)
found.invalid = true
- } else {
- found.extraneous = false
}
deps[d] = found
}
@@ -337,8 +336,6 @@ function findUnmet (obj, opts) {
if (!dependency) return
- dependency.extraneous = false
-
if (!semver.satisfies(dependency.version, peerDeps[d], true)) {
dependency.peerInvalid = true
}
@@ -347,6 +344,28 @@ function findUnmet (obj, opts) {
return obj
}
+function recursivelyMarkExtraneous (obj, extraneous) {
+ // stop recursion if we're not changing anything
+ if (obj.extraneous === extraneous) return
+
+ obj.extraneous = extraneous
+ var deps = obj.dependencies = obj.dependencies || {}
+ Object.keys(deps).forEach(function(d){
+ recursivelyMarkExtraneous(deps[d], extraneous)
+ });
+}
+
+function markExtraneous (obj) {
+ // start from the root object and mark as non-extraneous all modules that haven't been previously flagged as
+ // extraneous then propagate to all their dependencies
+ var deps = obj.dependencies = obj.dependencies || {}
+ Object.keys(deps).forEach(function(d){
+ if (!deps[d].extraneous){
+ recursivelyMarkExtraneous(deps[d], false);
+ }
+ });
+}
+
function copy (obj) {
if (!obj || typeof obj !== 'object') return obj
if (Array.isArray(obj)) return obj.map(copy)
View
17 node_modules/read-installed/test/extraneous.js
@@ -0,0 +1,17 @@
+var readInstalled = require('../read-installed.js')
+var test = require('tap').test
+var path = require('path');
+
+test('extraneous detected', function(t) {
+ // This test verifies read-installed#16
+ readInstalled(
+ path.join(__dirname, 'fixtures/extraneous-detected'),
+ { log: console.error },
+ function(err, map) {
+ t.ok(map.dependencies.foo.extraneous, 'foo is extraneous, it\'s not required by any module')
+ t.ok(map.dependencies.bar.extraneous, 'bar is extraneous, it\'s not required by any module')
+ t.notOk(map.dependencies.asdf.extraneous, 'asdf is not extraneous, it\'s required by ghjk')
+ t.notOk(map.dependencies.ghjk.extraneous, 'ghjk is not extraneous, it\'s required by our root module')
+ t.end();
+ })
+})
View
7 node_modules/read-installed/test/fixtures/extraneous-detected/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "extraneous-detected",
+ "version": "0.0.0",
+ "dependencies": {
+ "ghjk": "0.0.0"
+ }
+}
View
2  package.json
@@ -70,7 +70,7 @@
"osenv": "0",
"path-is-inside": "~1.0.0",
"read": "~1.0.4",
- "read-installed": "^2.0.0",
+ "read-installed": "~2.0.1",
"read-package-json": "~1.1.8",
"request": "~2.30.0",
"retry": "~0.6.0",
Please sign in to comment.
Something went wrong with that request. Please try again.