npm-package-arg@2.0.0

This commit is contained in:
Forrest L Norvell
2014-06-25 18:16:25 -07:00
parent 2793877f5b
commit 4f54043709
6 changed files with 35 additions and 19 deletions

View File

@@ -12,19 +12,18 @@ function mapToRegistry(name, config, cb) {
// the name itself takes precedence
var data = npa(name)
if (data.scope) {
// the name is definitely scoped, so escape now
name = name.replace("/", "%2f")
var packageScope = "@" + data.scope
if (!packageScope) return cb(new Error("No scope found in scoped package named " + name))
log.silly("mapToRegistry", "packageScope", packageScope)
log.silly("mapToRegistry", "scope", data.scope)
scopedRegistry = config.get(packageScope + ":registry")
scopedRegistry = config.get(data.scope + ":registry")
if (scopedRegistry) {
log.silly("mapToRegistry", "scopedRegistry (scoped package)", scopedRegistry)
uri = url.resolve(scopedRegistry, name)
}
else {
log.verbose("mapToRegistry", "no registry URL found for scope", packageScope)
log.verbose("mapToRegistry", "no registry URL found for scope", data.scope)
}
}

View File

@@ -50,3 +50,6 @@ fields:
* `raw` - The original un-modified string that was provided.
* `rawSpec` - The part after the `name@...`, as it was originally
provided.
* `scope` - If a name is something like `@org/module` then the `scope`
field will be set to `org`. If it doesn't have a scoped name, then
scope is `null`.

View File

@@ -46,7 +46,8 @@ function npa (arg) {
if (nameparse && validName(nameparse[3]) &&
(!nameparse[2] || validName(nameparse[2]))) {
res.name = (nameparse[1] || "") + nameparse[3]
res.scope = nameparse[2] || null
if (nameparse[2])
res.scope = "@" + nameparse[2]
arg = arg.substr(nameparse[0].length)
} else {
res.name = null
@@ -100,7 +101,8 @@ function npa (arg) {
res.spec = "*"
res.rawSpec = ""
res.name = arg
res.scope = p[1] || null
if (p[1])
res.scope = "@" + p[1]
} else {
parseLocal(res, arg)
}

View File

@@ -1,6 +1,6 @@
{
"name": "npm-package-arg",
"version": "1.1.0",
"version": "2.0.0",
"description": "Parse the things that can be arguments to `npm install`",
"main": "npa.js",
"directories": {
@@ -29,10 +29,10 @@
"url": "https://github.com/npm/npm-package-arg/issues"
},
"homepage": "https://github.com/npm/npm-package-arg",
"gitHead": "3bc0a6195ffb0396e8598fefed54f64b5b40723d",
"_id": "npm-package-arg@1.1.0",
"_shasum": "4546d1cf7d6c25bd1addd605ebc5a040778a2cd6",
"_from": "npm-package-arg@~1.1.0",
"gitHead": "e8b8d15b13bc254c64702a265668d35bb1cc27e0",
"_id": "npm-package-arg@2.0.0",
"_shasum": "b573aa01f3405c085564dfec930e8acc199bee08",
"_from": "npm-package-arg@>=2.0.0-0 <2.1.0-0",
"_npmVersion": "1.4.16",
"_npmUser": {
"name": "isaacs",
@@ -42,11 +42,15 @@
{
"name": "isaacs",
"email": "i@izs.me"
},
{
"name": "othiym23",
"email": "ogd@aoaioxxysz.net"
}
],
"dist": {
"shasum": "4546d1cf7d6c25bd1addd605ebc5a040778a2cd6",
"tarball": "http://registry.npmjs.org/npm-package-arg/-/npm-package-arg-1.1.0.tgz"
"shasum": "b573aa01f3405c085564dfec930e8acc199bee08",
"tarball": "http://registry.npmjs.org/npm-package-arg/-/npm-package-arg-2.0.0.tgz"
},
"_resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-1.1.0.tgz"
"_resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-2.0.0.tgz"
}

View File

@@ -16,7 +16,7 @@ require("tap").test("basic", function (t) {
"@foo/bar": {
raw: "@foo/bar",
name: "@foo/bar",
scope: "foo",
scope: "@foo",
rawSpec: "",
spec: "*",
type: "range"
@@ -25,7 +25,7 @@ require("tap").test("basic", function (t) {
"@foo/bar@": {
raw: "@foo/bar@",
name: "@foo/bar",
scope: "foo",
scope: "@foo",
rawSpec: "",
spec: "*",
type: "range"
@@ -34,7 +34,7 @@ require("tap").test("basic", function (t) {
"@foo/bar@baz": {
raw: "@foo/bar@baz",
name: "@foo/bar",
scope: "foo",
scope: "@foo",
rawSpec: "baz",
spec: "baz",
type: "tag"
@@ -70,6 +70,14 @@ require("tap").test("basic", function (t) {
raw: "git://github.com/user/foo"
},
"@foo/bar@git+ssh://github.com/user/foo": {
name: "@foo/bar",
scope: "@foo",
spec: "ssh://github.com/user/foo",
rawSpec: "git+ssh://github.com/user/foo",
raw: "@foo/bar@git+ssh://github.com/user/foo"
},
"/path/to/foo": {
name: null,
type: "local",

View File

@@ -64,7 +64,7 @@
"nopt": "~3.0.1",
"npm-cache-filename": "~1.0.1",
"npm-install-checks": "~1.0.2",
"npm-package-arg": "~1.1.0",
"npm-package-arg": "~2.0.0",
"npm-registry-client": "git://github.com/npm/npm-registry-client#othiym23/multi-registry",
"npm-user-validate": "~0.1.0",
"npmconf": "git://github.com/npm/npmconf.git#othiym23/new-credentials",