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:
-rw-r--r--doc/config.md28
-rw-r--r--lib/init.js10
-rw-r--r--lib/utils/config-defs.js8
3 files changed, 45 insertions, 1 deletions
diff --git a/doc/config.md b/doc/config.md
index 8b0d43872..244d38e91 100644
--- a/doc/config.md
+++ b/doc/config.md
@@ -249,6 +249,34 @@ user.
The gzip binary
+### init.version
+
+* Default: "0.0.0"
+* Type: String
+
+The value `npm init` should use by default for the package version.
+
+### init.author.name
+
+* Default: "0.0.0"
+* Type: String
+
+The value `npm init` should use by default for the package author's name.
+
+### init.author.email
+
+* Default: "0.0.0"
+* Type: String
+
+The value `npm init` should use by default for the package author's email.
+
+### init.author.url
+
+* Default: "0.0.0"
+* Type: String
+
+The value `npm init` should use by default for the package author's homepage.
+
### logfd
* Default: stderr file descriptor
diff --git a/lib/init.js b/lib/init.js
index e00f7a43e..38b69e415 100644
--- a/lib/init.js
+++ b/lib/init.js
@@ -24,6 +24,12 @@ function init (args, cb) {
readJson(path.join(folder, "package.json"), function (er, data) {
if (er) data = {}
+
+ data.author = data.author ||
+ { name: npm.config.get("init.author.name")
+ , email: npm.config.get("init.author.email")
+ , url: npm.config.get("init.author.url") }
+
init_(data, folder, function (er) {
npm.config.set("loglevel", ll)
if (!er) log(path.join(folder, "package.json"), "written")
@@ -207,7 +213,7 @@ function defaultLibWalker (folder, name, cb) {
// sync - no io
function defaultName (folder, data) {
if (data.name) return data.name
- return path.basename(folder).replace(/^node[_-]?|[-\.]?js$/g, '')
+ return path.basename(folder).replace(/^node[_-]?|[-\.]?js$/g, "")
}
function defaultVersion (folder, data, cb) {
@@ -216,6 +222,8 @@ function defaultVersion (folder, data, cb) {
function (er, code, out) {
out = (out || "").trim()
if (semver.valid(out)) return cb(null, out)
+ out = npm.config.get("init.version")
+ if (semver.valid(out)) return cb(null, out)
return cb(null, "0.0.0")
})
}
diff --git a/lib/utils/config-defs.js b/lib/utils/config-defs.js
index 4e43fac21..df8dec060 100644
--- a/lib/utils/config-defs.js
+++ b/lib/utils/config-defs.js
@@ -34,6 +34,10 @@ Object.defineProperty(exports, "defaults", {get: function () {
, globalconfig : path.resolve(process.execPath, "..", "..", "etc", "npmrc")
, group : process.env.SUDO_GID || process.getgid()
, gzipbin : process.env.GZIPBIN || "gzip"
+ , "init.version" : "0.0.0"
+ , "init.author.name" : ""
+ , "init.author.email" : ""
+ , "init.author.url" : ""
, logfd : stdio.stderrFD
, loglevel : "warn"
, long : false
@@ -86,6 +90,10 @@ exports.types =
, globalconfig : path
, group : [String, Number]
, gzipbin : String
+ , "init.version" : String
+ , "init.author.name" : String
+ , "init.author.email" : String
+ , "init.author.url" : String
, logfd : [Number, Stream]
, loglevel : ["silent","win","error","warn","info","verbose","silly"]
, long : Boolean