Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2015-07-01 03:47:44 +0300
committerRebecca Turner <me@re-becca.org>2015-07-01 14:30:39 +0300
commitedd744841fef5484bef7446e5a0288cb26426724 (patch)
treee2483d3d6e93593b56e0bbb7b0f3592364d7e823 /node_modules/read-package-tree
parentb259bcc8ba4ad990a7574a1f6fcb506e01966f7e (diff)
read-package-tree@5.0.0
Makes errors in the tree non-fatal, instead storing them in an error attribute.
Diffstat (limited to 'node_modules/read-package-tree')
-rw-r--r--node_modules/read-package-tree/README.md18
-rw-r--r--node_modules/read-package-tree/package.json31
-rw-r--r--node_modules/read-package-tree/rpt.js25
-rw-r--r--node_modules/read-package-tree/test/basic.js22
4 files changed, 59 insertions, 37 deletions
diff --git a/node_modules/read-package-tree/README.md b/node_modules/read-package-tree/README.md
index 5d76d0241..3ef0a4c79 100644
--- a/node_modules/read-package-tree/README.md
+++ b/node_modules/read-package-tree/README.md
@@ -10,12 +10,15 @@ rpt('/path/to/pkg/root', function (er, data) {
// er means that something didn't work.
// data is a structure like:
// {
- // package: <package.json data, or null>
+ // package: <package.json data, or an empty object>
+ // package.name: defaults to `basename(path)`
// children: [ <more things like this> ]
// parent: <thing that has this in its children property, or null>
// path: <path loaded>
// realpath: <the real path on disk>
+ // isLink: <set if this is a Link>
// target: <if a Link, then this is the actual Node>
+ // error: <if set, the error we got loading/parsing the package.json>
// }
})
```
@@ -48,9 +51,12 @@ may contain cycles.
## Errors
-Errors parsing or finding a package.json in node_modules will call back with
-an error object and no tree.
+Errors parsing or finding a package.json in node_modules will result in a
+node with the error property set. We will still find deeper node_modules
+if any exist. *Prior to `5.0.0` these aborted tree reading with an error
+callback.*
-A missing or invalid top level package.json will call back with an error
-object AND a tree, so that you may, at your discretion, choose to ignore
-the error.
+Only a few classes of errors are fatal (result in an error callback):
+
+* If the top level location is entirely missing, that will error.
+* if `fs.realpath` returns an error for any path its trying to resolve.
diff --git a/node_modules/read-package-tree/package.json b/node_modules/read-package-tree/package.json
index 6b422d562..037b5c18d 100644
--- a/node_modules/read-package-tree/package.json
+++ b/node_modules/read-package-tree/package.json
@@ -1,36 +1,35 @@
{
"_args": [
[
- "read-package-tree@~4.1.0",
+ "read-package-tree@~5.0.0",
"/Users/rebecca/code/npm"
]
],
- "_from": "read-package-tree@>=4.1.0 <4.2.0",
- "_id": "read-package-tree@4.1.0",
+ "_from": "read-package-tree@>=5.0.0 <5.1.0",
+ "_id": "read-package-tree@5.0.0",
"_inCache": true,
"_location": "/read-package-tree",
- "_nodeVersion": "0.10.38",
+ "_nodeVersion": "0.12.4",
"_npmUser": {
"email": "me@re-becca.org",
"name": "iarna"
},
- "_npmVersion": "2.7.5",
+ "_npmVersion": "2.11.2",
"_phantomChildren": {},
"_requested": {
"name": "read-package-tree",
- "raw": "read-package-tree@~4.1.0",
- "rawSpec": "~4.1.0",
+ "raw": "read-package-tree@~5.0.0",
+ "rawSpec": "~5.0.0",
"scope": null,
- "spec": ">=4.1.0 <4.2.0",
+ "spec": ">=5.0.0 <5.1.0",
"type": "range"
},
"_requiredBy": [
"/"
],
- "_resolved": "https://registry.npmjs.org/read-package-tree/-/read-package-tree-4.1.0.tgz",
- "_shasum": "d42e418ed22d23d88f308e660ddbf0753be467c1",
+ "_shasum": "0960bb19bff77ec7e35c1ea7ca8208945ea4bfb2",
"_shrinkwrap": null,
- "_spec": "read-package-tree@~4.1.0",
+ "_spec": "read-package-tree@~5.0.0",
"_where": "/Users/rebecca/code/npm",
"author": {
"email": "i@izs.me",
@@ -56,10 +55,10 @@
"test": "test"
},
"dist": {
- "shasum": "d42e418ed22d23d88f308e660ddbf0753be467c1",
- "tarball": "http://registry.npmjs.org/read-package-tree/-/read-package-tree-4.1.0.tgz"
+ "shasum": "0960bb19bff77ec7e35c1ea7ca8208945ea4bfb2",
+ "tarball": "http://registry.npmjs.org/read-package-tree/-/read-package-tree-5.0.0.tgz"
},
- "gitHead": "14162fb39841acac16ecaad5e9b79e65b430a1fb",
+ "gitHead": "57ab023d0a50214b5ea73887adb874723a4b0232",
"homepage": "https://github.com/npm/read-package-tree",
"license": "ISC",
"main": "rpt.js",
@@ -77,10 +76,10 @@
"optionalDependencies": {},
"repository": {
"type": "git",
- "url": "https://github.com/npm/read-package-tree"
+ "url": "git+https://github.com/npm/read-package-tree.git"
},
"scripts": {
"test": "tap test/*.js"
},
- "version": "4.1.0"
+ "version": "5.0.0"
}
diff --git a/node_modules/read-package-tree/rpt.js b/node_modules/read-package-tree/rpt.js
index e6d283883..58b5928ed 100644
--- a/node_modules/read-package-tree/rpt.js
+++ b/node_modules/read-package-tree/rpt.js
@@ -20,11 +20,11 @@ rpt.Node = Node
rpt.Link = Link
var ID = 0
-function Node (pkg, logical, physical, cache) {
+function Node (pkg, logical, physical, er, cache) {
if (cache[physical]) return cache[physical]
if (!(this instanceof Node)) {
- return new Node(pkg, logical, physical, cache)
+ return new Node(pkg, logical, physical, er, cache)
}
cache[physical] = this
@@ -32,24 +32,27 @@ function Node (pkg, logical, physical, cache) {
debug(this.constructor.name, dpath(physical), pkg && pkg._id)
this.id = ID++
- this.package = pkg
+ this.package = pkg || {}
+ if (!this.package.name) this.package.name = path.basename(logical)
this.path = logical
this.realpath = physical
this.parent = null
this.isLink = false
this.children = []
+ this.error = er
}
Node.prototype.package = null
Node.prototype.path = ''
Node.prototype.realpath = ''
Node.prototype.children = null
+Node.prototype.error = null
-function Link (pkg, logical, physical, realpath, cache) {
+function Link (pkg, logical, physical, realpath, er, cache) {
if (cache[physical]) return cache[physical]
if (!(this instanceof Link)) {
- return new Link(pkg, logical, physical, realpath, cache)
+ return new Link(pkg, logical, physical, realpath, er, cache)
}
cache[physical] = this
@@ -59,11 +62,13 @@ function Link (pkg, logical, physical, realpath, cache) {
this.id = ID++
this.path = logical
this.realpath = realpath
- this.package = pkg
+ this.package = pkg || {}
+ if (!this.package.name) this.package.name = path.basename(logical)
this.parent = null
- this.target = new Node(pkg, logical, realpath, cache)
+ this.target = new Node(this.package, logical, realpath, er, cache)
this.isLink = true
this.children = this.target.children
+ this.error = er
}
Link.prototype = Object.create(Node.prototype, {
@@ -82,12 +87,12 @@ function loadNode (logical, physical, cache, cb) {
pkg = pkg || null
var node
if (physical === real) {
- node = new Node(pkg, logical, physical, cache)
+ node = new Node(pkg, logical, physical, er, cache)
} else {
- node = new Link(pkg, logical, physical, real, cache)
+ node = new Link(pkg, logical, physical, real, er, cache)
}
- cb(er, node)
+ cb(null, node)
})
})
}
diff --git a/node_modules/read-package-tree/test/basic.js b/node_modules/read-package-tree/test/basic.js
index ada43a51c..0f9a33621 100644
--- a/node_modules/read-package-tree/test/basic.js
+++ b/node_modules/read-package-tree/test/basic.js
@@ -91,8 +91,8 @@ test('deeproot', function (t) {
test('broken json', function (t) {
rpt(path.resolve(fixtures, 'bad'), function (er, d) {
- t.ok(er, 'Got an error object')
- t.equal(er && er.code, 'EJSONPARSE')
+ t.ok(d.error, 'Got an error object')
+ t.equal(d.error && d.error.code, 'EJSONPARSE')
t.ok(d, 'Got a tree')
t.end()
})
@@ -100,13 +100,25 @@ test('broken json', function (t) {
test('missing json does not obscure deeper errors', function (t) {
rpt(path.resolve(fixtures, 'empty'), function (er, d) {
+ var error = d.error
+ t.ok(error, 'Error reading json of top level')
+ t.equal(error && error.code, 'ENOENT')
+ var childError = d.children.length===1 && d.children[0].error
+ t.ok(childError, 'Error parsing JSON of child node')
+ t.equal(childError && childError.code, 'EJSONPARSE')
+ t.end()
+ })
+})
+test('missing folder', function (t) {
+ rpt(path.resolve(fixtures, 'does-not-exist'), function (er, d) {
t.ok(er, 'Got an error object')
- t.equal(er && er.code, 'EJSONPARSE')
- t.ok(!d, 'No tree on internal error')
+ t.equal(er && er.code, 'ENOENT')
+ t.ok(!d, 'No tree on top level error')
t.end()
})
})
+
function archyize (d, seen) {
seen = seen || {}
var path = d.path
@@ -114,7 +126,7 @@ function archyize (d, seen) {
path = d.target.path
}
- var label = d.package ? d.package._id + ' ' : ''
+ var label = d.package._id ? d.package._id + ' ' : ''
label += path.substr(cwd.length + 1)
if (d . target) {