diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2014-10-17 10:02:57 +0400 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2014-10-17 10:02:57 +0400 |
commit | 60c2942e13655d9ecdf6e0f1f97f10cb71a75255 (patch) | |
tree | 1ad3aa96acbb5fd211337cc6274c1b31f4148faf | |
parent | 1b5c95fbda77b87342bd48c5ecac5b1fd571ccfe (diff) |
realize-package-specifier@1.2.0
Handle names and rawSpecs more consistently.
-rw-r--r-- | node_modules/realize-package-specifier/index.js | 10 | ||||
-rw-r--r-- | node_modules/realize-package-specifier/package.json | 30 | ||||
-rw-r--r-- | node_modules/realize-package-specifier/test/basic.js | 34 | ||||
-rw-r--r-- | package.json | 2 |
4 files changed, 66 insertions, 10 deletions
diff --git a/node_modules/realize-package-specifier/index.js b/node_modules/realize-package-specifier/index.js index c0d610cf7..261ad6630 100644 --- a/node_modules/realize-package-specifier/index.js +++ b/node_modules/realize-package-specifier/index.js @@ -16,7 +16,7 @@ module.exports = function (spec, where, cb) { } var specpath = dep.type == "local" ? path.resolve(where, dep.spec) - : path.resolve(spec) + : path.resolve(dep.rawSpec? dep.rawSpec: dep.name) fs.stat(specpath, function (er, s) { if (er) return finalize() if (!s.isDirectory()) return finalize("local") @@ -25,7 +25,13 @@ module.exports = function (spec, where, cb) { }) }) function finalize(type) { - if (type != null) dep.type = type + if (type != null && type != dep.type) { + dep.type = type + if (! dep.rawSpec) { + dep.rawSpec = dep.name + dep.name = null + } + } if (dep.type == "local" || dep.type == "directory") dep.spec = specpath cb(null, dep) } diff --git a/node_modules/realize-package-specifier/package.json b/node_modules/realize-package-specifier/package.json index d306b0cf9..536457637 100644 --- a/node_modules/realize-package-specifier/package.json +++ b/node_modules/realize-package-specifier/package.json @@ -1,6 +1,6 @@ { "name": "realize-package-specifier", - "version": "1.1.0", + "version": "1.2.0", "description": "Like npm-package-arg, but more so, producing full file paths and differentiating local tar and directory sources.", "main": "index.js", "scripts": { @@ -25,13 +25,29 @@ "require-inject": "^1.1.0", "tap": "^0.4.12" }, - "readme": "realize-package-specifier\n-------------------------\n\nParse a package specifier, peeking at the disk to differentiate between\nlocal tarballs, directories and named modules. This implements the logic\nused by `npm install` and `npm cache` to determine where to get packages\nfrom.\n\n```javascript\nvar realizePackageSpecifier = require(\"realize-package-specifier\")\nrealizePackageSpecifier(\"foo.tar.gz\", \".\", function (err, package) {\n …\n})\n```\n\n* realizePackageSpecifier(*spec*, [*where*,] *callback*)\n\nParses *spec* using `npm-package-arg` and then uses stat to check to see if\nit refers to a local tarball or package directory. Stats are done relative\nto *where*. If it does then the local module is loaded. If it doesn't then\ntarget is left as a remote package specifier. Package directories are\nrecognized by the presence of a package.json in them.\n\n*spec* -- a package specifier, like: `foo@1.2`, or `foo@user/foo`, or\n`http://x.com/foo.tgz`, or `git+https://github.com/user/foo`\n\n*where* (optional, default: .) -- The directory in which we should look for\nlocal tarballs or package directories.\n\n*callback* function(*err*, *result*) -- Called once we've determined what\nkind of specifier this is. The *result* object will be very like the one\nreturned by `npm-package-arg` except with three differences: 1) There's a\nnew type of `directory`. 2) The `local` type only refers to tarballs. 2)\nFor all `local` and `directory` type results spec will contain the full path of\nthe local package.\n\n## Result Objects\n\nThe full definition of the result object is:\n\n* `name` - If known, the `name` field expected in the resulting pkg.\n* `type` - One of the following strings:\n * `git` - A git repo\n * `github` - A github shorthand, like `user/project`\n * `tag` - A tagged version, like `\"foo@latest\"`\n * `version` - A specific version number, like `\"foo@1.2.3\"`\n * `range` - A version range, like `\"foo@2.x\"`\n * `local` - A local file path\n * `directory` - A local package directory\n * `remote` - An http url (presumably to a tgz)\n* `spec` - The \"thing\". URL, the range, git repo, etc.\n* `raw` - The original un-modified string that was provided.\n* `rawSpec` - The part after the `name@...`, as it was originally\n provided.\n* `scope` - If a name is something like `@org/module` then the `scope`\n field will be set to `org`. If it doesn't have a scoped name, then\n scope is `null`.\n\n", - "readmeFilename": "README.md", - "gitHead": "7243d67f21a089b0670f3f3e254b98475b232b0b", + "gitHead": "39016343d5bd5572ab39374323e9588e54985910", "bugs": { "url": "https://github.com/npm/realize-package-specifier/issues" }, - "_id": "realize-package-specifier@1.1.0", - "_shasum": "b6922638b7224186ae9278bdebbb63cba23a0160", - "_from": "realize-package-specifier@1.1.0" + "_id": "realize-package-specifier@1.2.0", + "_shasum": "93364e40dee38369f92e9b0c76124500342132f2", + "_from": "realize-package-specifier@>=1.2.0 <1.3.0", + "_npmVersion": "2.1.2", + "_nodeVersion": "0.10.32", + "_npmUser": { + "name": "iarna", + "email": "me@re-becca.org" + }, + "maintainers": [ + { + "name": "iarna", + "email": "me@re-becca.org" + } + ], + "dist": { + "shasum": "93364e40dee38369f92e9b0c76124500342132f2", + "tarball": "http://registry.npmjs.org/realize-package-specifier/-/realize-package-specifier-1.2.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/realize-package-specifier/-/realize-package-specifier-1.2.0.tgz" } diff --git a/node_modules/realize-package-specifier/test/basic.js b/node_modules/realize-package-specifier/test/basic.js index ed69cae18..d5d8fc6c0 100644 --- a/node_modules/realize-package-specifier/test/basic.js +++ b/node_modules/realize-package-specifier/test/basic.js @@ -85,3 +85,37 @@ test("realize-package-specifier", function (t) { t.is(result.type, "github", "github package dependency") }) }) +test("named realize-package-specifier", function (t) { + t.plan(10) + + rps("a@a.tar.gz", function (err, result) { + t.is(result.type, "local", "named local tarball") + }) + rps("b@b", function (err, result) { + t.is(result.type, "directory", "named local package directory") + }) + rps("c@c", function (err, result) { + t.is(result.type, "tag", "remote package, non-package local directory") + }) + rps("d@d", function (err, result) { + t.is(result.type, "tag", "remote package, no local directory") + }) + rps("a@file:./a.tar.gz", function (err, result) { + t.is(result.type, "local", "local tarball") + }) + rps("b@file:./b", function (err, result) { + t.is(result.type, "directory", "local package directory") + }) + rps("c@file:./c", function (err, result) { + t.is(result.type, "local", "non-package local directory, specified with a file URL") + }) + rps("d@file:./d", function (err, result) { + t.is(result.type, "local", "no local directory, specified with a file URL") + }) + rps("e@e/1", function (err, result) { + t.is(result.type, "directory", "local package directory") + }) + rps("e@e/2", function (err, result) { + t.is(result.type, "github", "github package dependency") + }) +}) diff --git a/package.json b/package.json index 2afea93de..a519cd28c 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "read-installed": "~3.1.2", "read-package-json": "~1.2.7", "readable-stream": "~1.0.32", - "realize-package-specifier": "~1.1.0", + "realize-package-specifier": "~1.2.0", "request": "~2.45.0", "retry": "~0.6.1", "rimraf": "~2.2.8", |