diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2014-08-29 08:11:34 +0400 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2014-08-29 08:11:34 +0400 |
commit | ae1d590bdfc2476a4ed446e760fea88686e3ae05 (patch) | |
tree | 1de019f87b2b39e5f3b9f397a2b88d999738f9cc /node_modules/npm-package-arg | |
parent | b2f51aecadf585711e145b6516f99e7c05f53614 (diff) |
npm-package-arg@2.0.4
Work better with git treeishes with slashes in them.
Diffstat (limited to 'node_modules/npm-package-arg')
-rw-r--r-- | node_modules/npm-package-arg/npa.js | 11 | ||||
-rw-r--r-- | node_modules/npm-package-arg/package.json | 33 | ||||
-rw-r--r-- | node_modules/npm-package-arg/test/basic.js | 21 |
3 files changed, 56 insertions, 9 deletions
diff --git a/node_modules/npm-package-arg/npa.js b/node_modules/npm-package-arg/npa.js index 13570469b..7c6b4254e 100644 --- a/node_modules/npm-package-arg/npa.js +++ b/node_modules/npm-package-arg/npa.js @@ -133,7 +133,15 @@ function parseLocal (res, arg) { } function maybeGitHubShorthand (arg) { - return /^[^@ \/%]+\/[^@ \/%]+$/.test(arg) + // Note: This does not fully test the git ref format. + // See https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html + // + // The only way to do this properly would be to shell out to + // git-check-ref-format, and as this is a fast sync function, + // we don't want to do that. Just let git fail if it turns + // out that the commit-ish is invalid. + // GH usernames cannot start with . or - + return /^[^@%\/\s\.-][^@%\/\s]*\/[^@\s\/%]+(?:#.*)?$/.test(arg) } function parseUrl (res, arg, urlparse) { @@ -151,7 +159,6 @@ function parseUrl (res, arg, urlparse) { case 'http:': case 'https:': - case 'npm:': res.type = 'remote' res.spec = arg break diff --git a/node_modules/npm-package-arg/package.json b/node_modules/npm-package-arg/package.json index f4a1bcdc7..2eb973440 100644 --- a/node_modules/npm-package-arg/package.json +++ b/node_modules/npm-package-arg/package.json @@ -1,6 +1,6 @@ { "name": "npm-package-arg", - "version": "2.0.2", + "version": "2.0.4", "description": "Parse the things that can be arguments to `npm install`", "main": "npa.js", "directories": { @@ -29,10 +29,29 @@ "url": "https://github.com/npm/npm-package-arg/issues" }, "homepage": "https://github.com/npm/npm-package-arg", - "readme": "# npm-package-arg\n\nParse the things that can be arguments to `npm install`\n\nTakes an argument like `foo@1.2`, or `foo@user/foo`, or\n`http://x.com/foo.tgz`, or `git+https://github.com/user/foo`, and\nfigures out what type of thing it is.\n\n## USAGE\n\n```javascript\nvar assert = require(\"assert\")\nvar npa = require(\"npm-package-arg\")\n\n// Pass in the descriptor, and it'll return an object\nvar parsed = npa(\"foo@1.2\")\n\n// Returns an object like:\n// {\n// name: \"foo\", // The bit in front of the @\n// type: \"range\", // the type of descriptor this is\n// spec: \"1.2\" // the specifier for this descriptor\n// }\n\n// Completely unreasonable invalid garbage throws an error\n// Make sure you wrap this in a try/catch if you have not\n// already sanitized the inputs!\nassert.throws(function() {\n npa(\"this is not \\0 a valid package name or url\")\n})\n```\n\nFor more examples, see the test file.\n\n## Result Objects\n\nThe objects that are returned by npm-package-arg contain the following\nfields:\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 or folder path\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", - "readmeFilename": "README.md", - "gitHead": "2e21602126b7bda86a7db95f9939e43a6710b8be", - "_id": "npm-package-arg@2.0.2", - "_shasum": "e4f660c683068eccba9b27b4075cc00c0ccc6037", - "_from": "npm-package-arg@latest" + "gitHead": "b630a290e12ea7c83b389b7582067ddca052d357", + "_id": "npm-package-arg@2.0.4", + "_shasum": "15647a2d5bb3b673e7a76644d43ddce929b9f84a", + "_from": "npm-package-arg@2.0.4", + "_npmVersion": "2.0.0-beta.0", + "_npmUser": { + "name": "isaacs", + "email": "i@izs.me" + }, + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + }, + { + "name": "othiym23", + "email": "ogd@aoaioxxysz.net" + } + ], + "dist": { + "shasum": "15647a2d5bb3b673e7a76644d43ddce929b9f84a", + "tarball": "http://registry.npmjs.org/npm-package-arg/-/npm-package-arg-2.0.4.tgz" + }, + "_resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-2.0.4.tgz", + "readme": "ERROR: No README data found!" } diff --git a/node_modules/npm-package-arg/test/basic.js b/node_modules/npm-package-arg/test/basic.js index 6a96c24c4..6dddc6378 100644 --- a/node_modules/npm-package-arg/test/basic.js +++ b/node_modules/npm-package-arg/test/basic.js @@ -99,6 +99,27 @@ require("tap").test("basic", function (t) { raw: "user/foo-js" }, + "user/foo-js#bar/baz": { + name: null, + type: "github", + spec: "user/foo-js#bar/baz", + raw: "user/foo-js#bar/baz" + }, + + "user..blerg--/..foo-js# . . . . . some . tags / / /": { + name: null, + type: "github", + spec: "user..blerg--/..foo-js# . . . . . some . tags / / /", + raw: "user..blerg--/..foo-js# . . . . . some . tags / / /" + }, + + "user/foo-js#bar/baz/bin": { + name: null, + type: "github", + spec: "user/foo-js#bar/baz/bin", + raw: "user/foo-js#bar/baz/bin" + }, + "foo@user/foo-js": { name: "foo", type: "github", |