Skip to content

Commit 0b1e09e

Browse files
committed
chore: replace var with const/let in lib/repo.js
1 parent ab0f026 commit 0b1e09e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/repo.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ module.exports = repo
22

33
repo.usage = 'npm repo [<pkg>]'
44

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')
99

1010
repo.completion = function (opts, cb) {
1111
// FIXME: there used to be registry completion here, but it stopped making
@@ -14,20 +14,20 @@ repo.completion = function (opts, cb) {
1414
}
1515

1616
function repo (args, cb) {
17-
var n = args.length ? args[0] : '.'
17+
const n = args.length ? args[0] : '.'
1818
fetchPackageMetadata(n, '.', {fullMetadata: true}, function (er, d) {
1919
if (er) return cb(er)
2020
getUrlAndOpen(d, cb)
2121
})
2222
}
2323

2424
function getUrlAndOpen (d, cb) {
25-
var r = d.repository
25+
const r = d.repository
2626
if (!r) return cb(new Error('no repository'))
2727
// XXX remove this when npm@v1.3.10 from node 0.10 is deprecated
2828
// 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)
3131

3232
if (!url) return cb(new Error('no repository: could not get url'))
3333

@@ -36,12 +36,12 @@ function getUrlAndOpen (d, cb) {
3636

3737
function unknownHostedUrl (url) {
3838
try {
39-
var idx = url.indexOf('@')
39+
const idx = url.indexOf('@')
4040
if (idx !== -1) {
4141
url = url.slice(idx + 1).replace(/:([^\d]+)/, '/$1')
4242
}
4343
url = url_.parse(url)
44-
var protocol = url.protocol === 'https:'
44+
const protocol = url.protocol === 'https:'
4545
? 'https:'
4646
: 'http:'
4747
return protocol + '//' + (url.host || '') +

0 commit comments

Comments
 (0)