Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

Commit 0223389

Browse files
tjdomenic
authored andcommitted
add "repo" command
1 parent b17e07c commit 0223389

12 files changed

Lines changed: 219 additions & 2 deletions

File tree

doc/api/repo.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
npm-repo(3) -- Open package repository page in the browser
2+
========================================================
3+
4+
## SYNOPSIS
5+
6+
npm.commands.repo(package, callback)
7+
8+
## DESCRIPTION
9+
10+
This command tries to guess at the likely location of a package's
11+
repository URL, and then tries to open it using the `--browser`
12+
config param.
13+
14+
Like other commands, the first parameter is an array. This command only
15+
uses the first element, which is expected to be a package name with an
16+
optional version number.
17+
18+
This command will launch a browser, so this command may not be the most
19+
friendly for programmatic use.

doc/cli/repo.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
npm-repo(1) -- Open package repository page in the browser
2+
========================================================
3+
4+
## SYNOPSIS
5+
6+
npm repo <pkgname>
7+
8+
## DESCRIPTION
9+
10+
This command tries to guess at the likely location of a package's
11+
repository URL, and then tries to open it using the `--browser`
12+
config param.
13+
14+
## CONFIGURATION
15+
16+
### browser
17+
18+
* Default: OS X: `"open"`, Windows: `"start"`, Others: `"xdg-open"`
19+
* Type: String
20+
21+
The browser that is called by the `npm repo` command to open websites.
22+
23+
## SEE ALSO
24+
25+
* npm-docs(1)
26+
* npm-config(1)

lib/npm.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ var commandCache = {}
146146
, "edit"
147147
, "explore"
148148
, "docs"
149+
, "repo"
149150
, "bugs"
150151
, "faq"
151152
, "root"

lib/repo.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
module.exports = repo
3+
4+
repo.usage = "npm repo <pkgname>"
5+
6+
repo.completion = function (opts, cb) {
7+
if (opts.conf.argv.remain.length > 2) return cb()
8+
registry.get("/-/short", 60000, function (er, list) {
9+
return cb(null, list || [])
10+
})
11+
}
12+
13+
var npm = require("./npm.js")
14+
, registry = npm.registry
15+
, log = require("npmlog")
16+
, opener = require("opener")
17+
, github = require('github-url-from-git')
18+
19+
function repo (args, cb) {
20+
if (!args.length) return cb(repo.usage)
21+
var n = args[0].split("@").shift()
22+
registry.get(n + "/latest", 3600, function (er, d) {
23+
if (er) return cb(er)
24+
var r = d.repository;
25+
if (!r) return cb(new Error('no repository'));
26+
var url = github(r.url);
27+
opener(url, { command: npm.config.get("browser") }, cb)
28+
})
29+
}

node_modules/github-url-from-git/.npmignore

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/github-url-from-git/History.md

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/github-url-from-git/Makefile

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/github-url-from-git/Readme.md

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/github-url-from-git/index.js

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/github-url-from-git/package.json

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)