diff options
author | isaacs <i@izs.me> | 2011-06-29 22:56:21 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-06-29 22:56:21 +0400 |
commit | 8a268945ea1f25b8ffb2fa186952be7823921d91 (patch) | |
tree | 45d5d4f06bc1a40f77f79daf6b66837205ba65dc /lib/init.js | |
parent | d146e855ff33f8912a247f6ce85a4905f778fbf0 (diff) |
Style, and remove an unnecessary chdir
Diffstat (limited to 'lib/init.js')
-rw-r--r-- | lib/init.js | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/lib/init.js b/lib/init.js index a16175cbb..09f768829 100644 --- a/lib/init.js +++ b/lib/init.js @@ -32,7 +32,7 @@ function init (args, cb) { init_(data, folder, function (er) { npm.config.set("loglevel", ll) - if (!er) log(path.join(folder, "package.json"), "written") + if (!er) log(path.resolve(folder, "package.json"), "written") cb(er) }) }) @@ -42,8 +42,13 @@ function init_ (data, folder, cb) { output.write( ["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")) @@ -74,15 +79,16 @@ function init_ (data, folder, cb) { ) ( defaultRepo, [folder, data], function (r) { data.repository = r } ) (function (cb) { - prompt("Project git repository: " - , data.repository && data.repository.url || "none" - , function (er, r) { - if (er) return cb(er) - if (r !== "none") { - data.repository = (data.repository || {}).url = r - } - cb() - }) + prompt( "Project git repository: " + , data.repository && data.repository.url || "none" + , function (er, r) { + if (er) return cb(er) + if (r !== "none") { + data.repository = (data.repository || {}).url = r + } + cb() + } + ) }, []) ( prompt , ["Author name: ", data.author && data.author.name] @@ -168,7 +174,7 @@ function init_ (data, folder, cb) { function defaultName (folder, data) { if (data.name) return data.name return path.basename(folder) - .replace(/^node[_-]?|([-\._]node)[-_\.]?(js)?$/g, "") + .replace(/^node[-\._]?|([-\._]node)[-\._]?(js)?$/g, "") } function defaultVersion (folder, data, cb) { @@ -185,18 +191,19 @@ function defaultVersion (folder, data, cb) { function defaultRepo (folder, data, cb) { if (data.repository) return cb(null, data.repository) - process.chdir(folder) - exec("git", ["remote", "-v"], process.env, false, function (er, code, out) { + exec( "git", ["remote", "-v"], process.env, false, folder + , function (er, code, out) { out = (out || "") .trim() .split("\n").filter(function (line) { return line.search(/^origin/) !== -1 })[0] if (!out) return cb(null, {}) - repo = { - type: "git" - , url: out.split(/\s/)[1].replace("git@github.com:", "git://github.com/") - } + var repo = + { type: "git" + , url: out.split(/\s/)[1] + .replace("git@github.com:", "git://github.com/") + } return cb(null, repo) }) } |