2 // initialize a package.json file
6 var log = require("npmlog")
7 , npm = require("./npm.js")
8 , initJson = require("init-package-json")
10 init.usage = "npm init [--force/-f]"
12 function init (args, cb) {
13 var dir = process.cwd()
16 var initFile = npm.config.get("init-module")
17 if (!initJson.yes(npm.config)) {
19 ["This utility will walk you through creating a package.json file."
20 ,"It only covers the most common items, and tries to guess sensible defaults."
22 ,"See `npm help json` for definitive documentation on these fields"
23 ,"and exactly what they do."
25 ,"Use `npm install <pkg> --save` afterwards to install a package and"
26 ,"save it as a dependency in the package.json file."
28 ,"Press ^C at any time to quit."
31 initJson(dir, initFile, npm.config, function (er, data) {
33 log.silly("package data", data)
34 if (er && er.message === "canceled") {
35 log.warn("init", "canceled")
38 log.info("init", "written successfully")