diff options
author | Michael Nisi <michael.nisi@gmail.com> | 2014-08-12 18:39:49 +0400 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2014-09-19 10:36:07 +0400 |
commit | fb5724fd98e1509c939693568df83d11417ea337 (patch) | |
tree | f4a27da749b52df51ef12836c14936c0ce9198c2 /lib | |
parent | 1259d85d78405b4c48becba8dcec6d8adf1bc3f6 (diff) |
Allow init without prompt
Diffstat (limited to 'lib')
-rw-r--r-- | lib/init.js | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/lib/init.js b/lib/init.js index 8ae991f5b..925654bee 100644 --- a/lib/init.js +++ b/lib/init.js @@ -7,33 +7,33 @@ var log = require("npmlog") , npm = require("./npm.js") , initJson = require("init-package-json") -init.usage = "npm init" +init.usage = "npm init [--force/-f]" function init (args, cb) { var dir = process.cwd() log.pause() npm.spinner.stop() - var initFile = npm.config.get('init-module') - - console.log( - ["This utility will walk you through creating a package.json file." - ,"It only covers the most common items, and tries to guess sane defaults." - ,"" - ,"See `npm help json` for definitive documentation on these fields" - ,"and exactly what they do." - ,"" - ,"Use `npm install <pkg> --save` afterwards to install a package and" - ,"save it as a dependency in the package.json file." - ,"" - ,"Press ^C at any time to quit." - ].join("\n")) - + var initFile = npm.config.get("init-module") + if (!initJson.yes(npm.config)) { + console.log( + ["This utility will walk you through creating a package.json file." + ,"It only covers the most common items, and tries to guess sane defaults." + ,"" + ,"See `npm help json` for definitive documentation on these fields" + ,"and exactly what they do." + ,"" + ,"Use `npm install <pkg> --save` afterwards to install a package and" + ,"save it as a dependency in the package.json file." + ,"" + ,"Press ^C at any time to quit." + ].join("\n")) + } initJson(dir, initFile, npm.config, function (er, data) { log.resume() - log.silly('package data', data) - log.info('init', 'written successfully') - if (er && er.message === 'canceled') { - log.warn('init', 'canceled') + log.silly("package data", data) + log.info("init", "written successfully") + if (er && er.message === "canceled") { + log.warn("init", "canceled") return cb(null, data) } cb(er, data) |