Skip to content

Commit

Permalink
chore: replace var with const/let
Browse files Browse the repository at this point in the history
  • Loading branch information
watilde committed Dec 14, 2018
1 parent ab0f026 commit 0edf0bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/fetch-package-metadata.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fetch-package-metadata
----------------------

var fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
const fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
fetchPackageMetadata(spec, contextdir, callback)

This will get package metadata (and if possible, ONLY package metadata) for
Expand Down
20 changes: 10 additions & 10 deletions lib/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 npm@v1.3.10 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'))

Expand All @@ -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 || '') +
Expand Down

0 comments on commit 0edf0bd

Please sign in to comment.