allow semver@4
v1.0.1
Make init prompt optional
1.1.0
ensure that npm environmental config gets used
add .gitignore
1.1.1
config values can be dotted OR dashed

Closes npm/npm#6642 without regressing npm/npm#6483, and includes tests
to prevent further regression. The problem here was letting in
`init.author.name` as a property name, which is incompatible with how
npm maps environment variable names to config keys
(`npm_config_init_author_name` → `init-author-name`), and is also out of
whack with the convention used for command-line variable names
(`--init.author-name="Blast Hardcheese"` vs `--init-author-name="Blast
Hardcheese"`).

To fix the regression and avoid retroactively introducing an unflagged
breaking change into npm, check the config for either `init.author.name`
and `init-author-name`, with the first one found (in that order)
winning.'
diff --git a/default-input.js b/default-input.js index c86894b..9f459f0
100644 --- a/default-input.js +++ b/default-input.js @@ -41,7 +41,10 @@
function readDeps (test) { return function (cb) { var name =
package.name || basename exports.name = yes ? name : prompt('name',
name)

-var version = package.version || config.get('init-version') || '1.0.0'
+var version = package.version ||
+              config.get('init-version') ||
+              config.get('init.version') ||
+              '1.0.0'
 exports.version = yes ? version : prompt('version', version)

 if (!package.description) {
@@ -177,14 +180,21 @@ if (!package.keywords) {
 }

 if (!package.author) {
-  exports.author = config.get('init-author-name')
+  exports.author = config.get('init-author-name') ||
+                   config.get('init.author.name')
   ? {
-      "name" : config.get('init-author-name'),
-      "email" : config.get('init-author-email'),
-      "url" : config.get('init-author-url')
+      "name" : config.get('init-author-name') ||
+               config.get('init.author.name'),
+      "email" : config.get('init-author-email') ||
+                config.get('init.author.email'),
+      "url" : config.get('init-author-url') ||
+              config.get('init.author.url')
     }
   : prompt('author')
 }

-var license = package.license || config.get('init-license') || 'ISC'
+var license = package.license ||
+              config.get('init-license') ||
+              config.get('init.license') ||
+              'ISC'
 exports.license = yes ? license : prompt('license', license)
diff --git a/test/npm-defaults.js b/test/npm-defaults.js
index 8229c84..cc46a8e 100644
--- a/test/npm-defaults.js
+++ b/test/npm-defaults.js
@@ -42,6 +42,58 @@ test("npm configuration values pulled from environment", function (t) {
   })
 })

+test("npm configuration values pulled from dotted config", function (t) {
+  /*eslint camelcase:0 */
+  var config = {
+    yes : "yes",
+
+    "init.author.name"  : "npmbot",
+    "init.author.email" : "n@p.m",
+    "init.author.url"   : "http://npm.im",
+
+    "init.license" : EXPECTED.license,
+    "init.version" : EXPECTED.version
+  }
+
+  npm.load(config, function (err) {
+    t.ifError(err, "npm loaded successfully")
+
+    process.chdir(resolve(__dirname))
+    init(__dirname, __dirname, npm.config, function (er, data) {
+      t.ifError(err, "init ran successfully")
+
+      t.same(data, EXPECTED, "got the package data from the config")
+      t.end()
+    })
+  })
+})
+
+test("npm configuration values pulled from dashed config", function (t) {
+  /*eslint camelcase:0 */
+  var config = {
+    yes : "yes",
+
+    "init-author-name"  : "npmbot",
+    "init-author-email" : "n@p.m",
+    "init-author-url"   : "http://npm.im",
+
+    "init-license" : EXPECTED.license,
+    "init-version" : EXPECTED.version
+  }
+
+  npm.load(config, function (err) {
+    t.ifError(err, "npm loaded successfully")
+
+    process.chdir(resolve(__dirname))
+    init(__dirname, __dirname, npm.config, function (er, data) {
+      t.ifError(err, "init ran successfully")
+
+      t.same(data, EXPECTED, "got the package data from the config")
+      t.end()
+    })
+  })
+})
+
 test("cleanup", function (t) {
   rimraf.sync(resolve(__dirname, "package.json"))
   t.pass("cleaned up")
1.1.2