Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2014-10-31 00:32:52 +0300
committerForrest L Norvell <forrest@npmjs.com>2014-10-31 11:18:12 +0300
commit239c3086cc1cbee651f9ec85609b8dd3ab8258d7 (patch)
treeb94499fc49bacecc3b5490e525dfd7d59dd43cbf /lib
parent7719cfdd8b204dfeccc41289707ea58b4d608905 (diff)
style tweaks
Diffstat (limited to 'lib')
-rw-r--r--lib/bugs.js2
-rw-r--r--lib/docs.js19
-rw-r--r--lib/owner.js3
-rw-r--r--lib/repo.js44
-rw-r--r--lib/search.js10
-rw-r--r--lib/view.js19
6 files changed, 48 insertions, 49 deletions
diff --git a/lib/bugs.js b/lib/bugs.js
index ea27bdd82..fabbbaf10 100644
--- a/lib/bugs.js
+++ b/lib/bugs.js
@@ -24,7 +24,7 @@ bugs.completion = function (opts, cb) {
}
function bugs (args, cb) {
- var n = args.length && npa(args[0]).name || '.'
+ var n = args.length && npa(args[0]).name || "."
fs.stat(n, function (er, s) {
if (er) {
if (er.code === "ENOENT") return callRegistry(n, cb)
diff --git a/lib/docs.js b/lib/docs.js
index 3abeda7e2..9abe740a3 100644
--- a/lib/docs.js
+++ b/lib/docs.js
@@ -4,6 +4,12 @@ docs.usage = "npm docs <pkgname>"
docs.usage += "\n"
docs.usage += "npm docs ."
+var npm = require("./npm.js")
+ , opener = require("opener")
+ , path = require("path")
+ , log = require("npmlog")
+ , mapToRegistry = require("./utils/map-to-registry.js")
+
docs.completion = function (opts, cb) {
mapToRegistry("/-/short", npm.config, function (er, uri, auth) {
if (er) return cb(er)
@@ -14,13 +20,6 @@ docs.completion = function (opts, cb) {
})
}
-var npm = require("./npm.js")
- , registry = npm.registry
- , opener = require("opener")
- , path = require("path")
- , log = require("npmlog")
- , mapToRegistry = require("./utils/map-to-registry.js")
-
function url (json) {
return json.homepage ? json.homepage : "https://npmjs.org/package/" + json.name
}
@@ -28,7 +27,7 @@ function url (json) {
function docs (args, cb) {
args = args || []
var pending = args.length
- if (!pending) return getDoc('.', cb)
+ if (!pending) return getDoc(".", cb)
args.forEach(function(proj) {
getDoc(proj, function(err) {
if (err) {
@@ -40,10 +39,10 @@ function docs (args, cb) {
}
function getDoc (project, cb) {
- project = project || '.'
+ project = project || "."
var package = path.resolve(npm.localPrefix, "package.json")
- if (project === '.' || project === './') {
+ if (project === "." || project === "./") {
var json
try {
json = require(package)
diff --git a/lib/owner.js b/lib/owner.js
index 7d3d1f1c3..7f18480fc 100644
--- a/lib/owner.js
+++ b/lib/owner.js
@@ -225,7 +225,8 @@ function mutate (pkg, user, mutation, cb) {
}
npm.registry.request(uri, params, function (er, data) {
if (!er && data.error) er = new Error(
- "Failed to update package metadata: " + JSON.stringify(data))
+ "Failed to update package metadata: " + JSON.stringify(data)
+ )
if (er) {
log.error("owner mutate", "Failed to update package metadata")
}
diff --git a/lib/repo.js b/lib/repo.js
index 98195cb6e..3db4a16bc 100644
--- a/lib/repo.js
+++ b/lib/repo.js
@@ -3,20 +3,9 @@ module.exports = repo
repo.usage = "npm repo <pkgname>"
-repo.completion = function (opts, cb) {
- if (opts.conf.argv.remain.length > 2) return cb()
- mapToRegistry("/-/short", npm.config, function (er, uri) {
- if (er) return cb(er)
-
- registry.get(uri, { timeout : 60000 }, function (er, list) {
- return cb(null, list || [])
- })
- })
-}
-
var npm = require("./npm.js")
, opener = require("opener")
- , github = require('github-url-from-git')
+ , github = require("github-url-from-git")
, githubUserRepo = require("github-url-from-username-repo")
, path = require("path")
, readJson = require("read-package-json")
@@ -25,6 +14,17 @@ var npm = require("./npm.js")
, mapToRegistry = require("./utils/map-to-registry.js")
, npa = require("npm-package-arg")
+repo.completion = function (opts, cb) {
+ if (opts.conf.argv.remain.length > 2) return cb()
+ mapToRegistry("/-/short", npm.config, function (er, uri) {
+ if (er) return cb(er)
+
+ npm.registry.get(uri, { timeout : 60000 }, function (er, list) {
+ return cb(null, list || [])
+ })
+ })
+}
+
function repo (args, cb) {
var n = args.length && npa(args[0]).name || "."
fs.stat(n, function (er, s) {
@@ -40,18 +40,18 @@ function repo (args, cb) {
function getUrlAndOpen (d, cb) {
var r = d.repository
- if (!r) return cb(new Error('no 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
if (githubUserRepo(r.url))
r.url = githubUserRepo(r.url)
- var url = (r.url && ~r.url.indexOf('github'))
+ var url = (r.url && ~r.url.indexOf("github"))
? github(r.url)
: nonGithubUrl(r.url)
if (!url)
- return cb(new Error('no repository: could not get url'))
+ return cb(new Error("no repository: could not get url"))
opener(url, { command: npm.config.get("browser") }, cb)
}
@@ -68,16 +68,16 @@ function callRegistry (n, cb) {
function nonGithubUrl (url) {
try {
- var idx = url.indexOf('@')
+ var idx = url.indexOf("@")
if (idx !== -1) {
- url = url.slice(idx+1).replace(/:([^\d]+)/, '/$1')
+ url = url.slice(idx+1).replace(/:([^\d]+)/, "/$1")
}
url = url_.parse(url)
- var protocol = url.protocol === 'https:'
- ? 'https:'
- : 'http:'
- return protocol + '//' + (url.host || '') +
- url.path.replace(/\.git$/, '')
+ var protocol = url.protocol === "https:"
+ ? "https:"
+ : "http:"
+ return protocol + "//" + (url.host || "") +
+ url.path.replace(/\.git$/, "")
}
catch(e) {}
}
diff --git a/lib/search.js b/lib/search.js
index d2ce9a3c0..68139a7ac 100644
--- a/lib/search.js
+++ b/lib/search.js
@@ -164,7 +164,7 @@ function prettify (data, args) {
dat.keywords = dat.keywords.split(/[,\s]+/)
}
if (Array.isArray(dat.keywords)) {
- dat.keywords = dat.keywords.join(' ')
+ dat.keywords = dat.keywords.join(" ")
}
// split author on whitespace or ,
@@ -172,7 +172,7 @@ function prettify (data, args) {
dat.author = dat.author.split(/[,\s]+/)
}
if (Array.isArray(dat.author)) {
- dat.author = dat.author.join(' ')
+ dat.author = dat.author.join(" ")
}
return dat
})
@@ -194,7 +194,7 @@ function prettify (data, args) {
include: columns
, truncate: truncate
, config: {
- name: { maxWidth: 40, truncate: false, truncateMarker: '' }
+ name: { maxWidth: 40, truncate: false, truncateMarker: "" }
, description: { maxWidth: 60 }
, author: { maxWidth: 20 }
, date: { maxWidth: 11 }
@@ -260,9 +260,9 @@ function getMaxWidth() {
function trimToMaxWidth(str) {
var maxWidth = getMaxWidth()
- return str.split('\n').map(function(line) {
+ return str.split("\n").map(function(line) {
return line.slice(0, maxWidth)
- }).join('\n')
+ }).join("\n")
}
function highlightSearchTerms(str, terms) {
diff --git a/lib/view.js b/lib/view.js
index c2605cf0a..bd20ab5a3 100644
--- a/lib/view.js
+++ b/lib/view.js
@@ -3,6 +3,15 @@
module.exports = view
view.usage = "npm view pkg[@version] [<field>[.subfield]...]"
+var npm = require("./npm.js")
+ , readJson = require("read-package-json")
+ , log = require("npmlog")
+ , util = require("util")
+ , semver = require("semver")
+ , mapToRegistry = require("./utils/map-to-registry.js")
+ , npa = require("npm-package-arg")
+ , path = require("path")
+
view.completion = function (opts, cb) {
if (opts.conf.argv.remain.length <= 2) {
return mapToRegistry("-/short", npm.config, function (er, uri, auth) {
@@ -48,16 +57,6 @@ view.completion = function (opts, cb) {
}
}
-var npm = require("./npm.js")
- , readJson = require("read-package-json")
- , registry = npm.registry
- , log = require("npmlog")
- , util = require("util")
- , semver = require("semver")
- , mapToRegistry = require("./utils/map-to-registry.js")
- , npa = require("npm-package-arg")
- , path = require("path")
-
function view (args, silent, cb) {
if (typeof cb !== "function") cb = silent, silent = false