@@ -2,10 +2,10 @@ module.exports = repo
2
2
3
3
repo . usage = 'npm repo [<pkg>]'
4
4
5
- var openUrl = require ( './utils/open-url' )
6
- var hostedGitInfo = require ( 'hosted-git-info' )
7
- var url_ = require ( 'url' )
8
- var fetchPackageMetadata = require ( './fetch-package-metadata.js' )
5
+ const openUrl = require ( './utils/open-url' )
6
+ const hostedGitInfo = require ( 'hosted-git-info' )
7
+ const url_ = require ( 'url' )
8
+ const fetchPackageMetadata = require ( './fetch-package-metadata.js' )
9
9
10
10
repo . completion = function ( opts , cb ) {
11
11
// FIXME: there used to be registry completion here, but it stopped making
@@ -14,20 +14,20 @@ repo.completion = function (opts, cb) {
14
14
}
15
15
16
16
function repo ( args , cb ) {
17
- var n = args . length ? args [ 0 ] : '.'
17
+ const n = args . length ? args [ 0 ] : '.'
18
18
fetchPackageMetadata ( n , '.' , { fullMetadata : true } , function ( er , d ) {
19
19
if ( er ) return cb ( er )
20
20
getUrlAndOpen ( d , cb )
21
21
} )
22
22
}
23
23
24
24
function getUrlAndOpen ( d , cb ) {
25
- var r = d . repository
25
+ const r = d . repository
26
26
if ( ! r ) return cb ( new Error ( 'no repository' ) )
27
27
// XXX remove this when npm@v 1.3.10 from node 0.10 is deprecated
28
28
// from https://github.com/npm/npm-www/issues/418
29
- var info = hostedGitInfo . fromUrl ( r . url )
30
- var url = info ? info . browse ( ) : unknownHostedUrl ( r . url )
29
+ const info = hostedGitInfo . fromUrl ( r . url )
30
+ const url = info ? info . browse ( ) : unknownHostedUrl ( r . url )
31
31
32
32
if ( ! url ) return cb ( new Error ( 'no repository: could not get url' ) )
33
33
@@ -36,12 +36,12 @@ function getUrlAndOpen (d, cb) {
36
36
37
37
function unknownHostedUrl ( url ) {
38
38
try {
39
- var idx = url . indexOf ( '@' )
39
+ const idx = url . indexOf ( '@' )
40
40
if ( idx !== - 1 ) {
41
41
url = url . slice ( idx + 1 ) . replace ( / : ( [ ^ \d ] + ) / , '/$1' )
42
42
}
43
43
url = url_ . parse ( url )
44
- var protocol = url . protocol === 'https:'
44
+ const protocol = url . protocol === 'https:'
45
45
? 'https:'
46
46
: 'http:'
47
47
return protocol + '//' + ( url . host || '' ) +
0 commit comments