Skip to content

Commit 0223ba8

Browse files
committed
init
0 parents  commit 0223ba8

File tree

5 files changed

+93
-0
lines changed

5 files changed

+93
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store*
2+
node_modules/

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2014 Jonathan Ong [email protected]
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
# npm repo
3+
4+
For people like me who __hate__ going to https://npmjs.org,
5+
a CLI utility to open a package's repository page.
6+
7+
```js
8+
npm-repo koa
9+
# opens up https://github.com/koajs/koa in your favorite browser
10+
```
11+
12+
## Installation
13+
14+
```js
15+
npm i -g npm-repo
16+
```

bin/npm-repo

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env node
2+
3+
var program = require('commander')
4+
.usage('[package name]')
5+
.parse(process.argv)
6+
7+
var name = program.args[0]
8+
if (!name) {
9+
console.error('a package name was not defined!')
10+
process.exit(1)
11+
}
12+
13+
require('request')('https://registry.npmjs.org/' + name, function (err, res, body) {
14+
if (err) {
15+
console.error(err.stack)
16+
process.exit(1)
17+
}
18+
if (res.statusCode !== 200) {
19+
console.error('a package by the name of "%s" was not found', name)
20+
process.exit(1)
21+
}
22+
body = JSON.parse(body) // you're useless, request!
23+
24+
var repo = body.repository
25+
if (!repo) {
26+
console.error('package "%s" did not define a repository', name)
27+
process.exit(1)
28+
}
29+
30+
var url = require('url')
31+
var obj = url.parse(repo.url)
32+
if (obj.protocol !== 'https:') obj.protocol = 'https:'
33+
require('open')(url.format(obj))
34+
})

package.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "npm-repo",
3+
"description": "open the repository page for an npm package",
4+
"version": "1.0.0",
5+
"author": {
6+
"name": "Jonathan Ong",
7+
"email": "[email protected]",
8+
"url": "http://jongleberry.com",
9+
"twitter": "https://twitter.com/jongleberry"
10+
},
11+
"license": "MIT",
12+
"repository": "repo-utils/npm-repo",
13+
"dependencies": {
14+
"open": "0",
15+
"request": "2",
16+
"commander": "2"
17+
},
18+
"bin": "bin/npm-repo"
19+
}

0 commit comments

Comments
 (0)