-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: replace var with const/let in lib/repo.js (#119)
PR-URL: #119 Credit: @watilde Reviewed-By: @aeschright
- Loading branch information
Showing
1 changed file
with
10 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,10 @@ module.exports = repo | |
|
||
repo.usage = 'npm repo [<pkg>]' | ||
|
||
var openUrl = require('./utils/open-url') | ||
var hostedGitInfo = require('hosted-git-info') | ||
var url_ = require('url') | ||
var fetchPackageMetadata = require('./fetch-package-metadata.js') | ||
const openUrl = require('./utils/open-url') | ||
const hostedGitInfo = require('hosted-git-info') | ||
const url_ = require('url') | ||
const fetchPackageMetadata = require('./fetch-package-metadata.js') | ||
|
||
repo.completion = function (opts, cb) { | ||
// FIXME: there used to be registry completion here, but it stopped making | ||
|
@@ -14,20 +14,20 @@ repo.completion = function (opts, cb) { | |
} | ||
|
||
function repo (args, cb) { | ||
var n = args.length ? args[0] : '.' | ||
const n = args.length ? args[0] : '.' | ||
fetchPackageMetadata(n, '.', {fullMetadata: true}, function (er, d) { | ||
if (er) return cb(er) | ||
getUrlAndOpen(d, cb) | ||
}) | ||
} | ||
|
||
function getUrlAndOpen (d, cb) { | ||
var r = d.repository | ||
const r = d.repository | ||
if (!r) return cb(new Error('no repository')) | ||
// XXX remove this when [email protected] from node 0.10 is deprecated | ||
// from https://github.com/npm/npm-www/issues/418 | ||
var info = hostedGitInfo.fromUrl(r.url) | ||
var url = info ? info.browse() : unknownHostedUrl(r.url) | ||
const info = hostedGitInfo.fromUrl(r.url) | ||
const url = info ? info.browse() : unknownHostedUrl(r.url) | ||
|
||
if (!url) return cb(new Error('no repository: could not get url')) | ||
|
||
|
@@ -36,12 +36,12 @@ function getUrlAndOpen (d, cb) { | |
|
||
function unknownHostedUrl (url) { | ||
try { | ||
var idx = url.indexOf('@') | ||
const idx = url.indexOf('@') | ||
if (idx !== -1) { | ||
url = url.slice(idx + 1).replace(/:([^\d]+)/, '/$1') | ||
} | ||
url = url_.parse(url) | ||
var protocol = url.protocol === 'https:' | ||
const protocol = url.protocol === 'https:' | ||
? 'https:' | ||
: 'http:' | ||
return protocol + '//' + (url.host || '') + | ||
|