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
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2015-06-23 08:18:52 +0300
committerRebecca Turner <me@re-becca.org>2015-06-26 03:27:33 +0300
commitb50be6aff34a739ca43de65f546e743d1a9975b9 (patch)
tree3153fd3a271245b8a05a9be196286fbe31fc9d44 /scripts
parent7c5ebe0552b7b5d0cdca34d28c4f16fe794ff2ff (diff)
src: make the npm source comply with `standard`
This is a huge set of mostly mechanical changes. Going forward, all changes to the npm source base are expected to comply with `standard`, and it's been integrated into the test suite to enforce that. There are a few notes below about specific classes of changes that need to be handled specially for npm's code base. standard: "Expected error to be handled." `standard` only expects errors spelled "err" to be handled. `npm-registry-mock` never actually invokes its callback with an error, so in some cases I just changed it to be spelled "er" and called it good. standard: "Expected a "break" statement before 'case'." This behavior is actually on purpose, and I don't feel like rewriting the affected code right now (or, you know, ever). So I added code comments disabling the checks in the three applicable changes. standard: "x is a function." Rebinding functions created via declarations (as opposed to expressions) is a no-no? PR-URL: https://github.com/npm/npm/pull/8668
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/index-build.js61
-rw-r--r--scripts/publish-tag.js4
2 files changed, 30 insertions, 35 deletions
diff --git a/scripts/index-build.js b/scripts/index-build.js
index 21297cc93..8fbbf8595 100755
--- a/scripts/index-build.js
+++ b/scripts/index-build.js
@@ -1,63 +1,58 @@
#!/usr/bin/env node
-var fs = require("fs")
- , path = require("path")
- , root = path.resolve(__dirname, "..")
- , glob = require("glob")
- , conversion = { "cli": 1, "api": 3, "files": 5, "misc": 7 }
-
-glob(root + "/{README.md,doc/*/*.md}", function (er, files) {
- if (er)
- throw er
+var fs = require('fs')
+var path = require('path')
+var root = path.resolve(__dirname, '..')
+var glob = require('glob')
+var conversion = { 'cli': 1, 'api': 3, 'files': 5, 'misc': 7 }
+
+glob(root + '/{README.md,doc/*/*.md}', function (er, files) {
+ if (er) throw er
+
output(files.map(function (f) {
var b = path.basename(f)
- if (b === "README.md")
- return [0, b]
- if (b === "index.md")
- return null
+ if (b === 'README.md') return [0, b]
+ if (b === 'index.md') return null
var s = conversion[path.basename(path.dirname(f))]
return [s, f]
}).filter(function (f) {
return f
}).sort(function (a, b) {
- return (a[0] === b[0])
- ? ( path.basename(a[1]) === "npm.md" ? -1
- : path.basename(b[1]) === "npm.md" ? 1
- : a[1] > b[1] ? 1 : -1 )
- : a[0] - b[0]
+ return (a[0] === b[0]) ?
+ (path.basename(a[1]) === 'npm.md' ? -1 :
+ path.basename(b[1]) === 'npm.md' ? 1 :
+ a[1] > b[1] ? 1 : -1) :
+ a[0] - b[0]
}))
})
-return
-
function output (files) {
console.log(
- "npm-index(7) -- Index of all npm documentation\n" +
- "==============================================\n")
+ 'npm-index(7) -- Index of all npm documentation\n' +
+ '==============================================\n')
writeLines(files, 0)
- writeLines(files, 1, "Command Line Documentation", "Using npm on the command line")
- writeLines(files, 3, "API Documentation", "Using npm in your Node programs")
- writeLines(files, 5, "Files", "File system structures npm uses")
- writeLines(files, 7, "Misc", "Various other bits and bobs")
+ writeLines(files, 1, 'Command Line Documentation', 'Using npm on the command line')
+ writeLines(files, 3, 'API Documentation', 'Using npm in your Node programs')
+ writeLines(files, 5, 'Files', 'File system structures npm uses')
+ writeLines(files, 7, 'Misc', 'Various other bits and bobs')
}
function writeLines (files, sxn, heading, desc) {
if (heading) {
- console.log("## %s\n\n%s\n", heading, desc)
+ console.log('## %s\n\n%s\n', heading, desc)
}
files.filter(function (f) {
return f[0] === sxn
}).forEach(writeLine)
}
-
function writeLine (sd) {
var sxn = sd[0] || 1
- , doc = sd[1]
- , d = path.basename(doc, ".md")
+ var doc = sd[1]
+ var d = path.basename(doc, '.md')
- var content = fs.readFileSync(doc, "utf8").split("\n")[0].split("-- ")[1]
+ var content = fs.readFileSync(doc, 'utf8').split('\n')[0].split('-- ')[1]
- console.log("### %s(%d)\n", d, sxn)
- console.log(content + "\n")
+ console.log('### %s(%d)\n', d, sxn)
+ console.log(content + '\n')
}
diff --git a/scripts/publish-tag.js b/scripts/publish-tag.js
index 046ec9888..d0c04556e 100644
--- a/scripts/publish-tag.js
+++ b/scripts/publish-tag.js
@@ -1,3 +1,3 @@
-var semver = require("semver")
-var version = semver.parse(require("../package.json").version)
+var semver = require('semver')
+var version = semver.parse(require('../package.json').version)
console.log('v%s.%s-next', version.major, version.minor)