diff options
Diffstat (limited to 'deps/npm/node_modules/init-package-json/default-input.js')
-rw-r--r-- | deps/npm/node_modules/init-package-json/default-input.js | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/deps/npm/node_modules/init-package-json/default-input.js b/deps/npm/node_modules/init-package-json/default-input.js index 8b335f9674..c86894b26a 100644 --- a/deps/npm/node_modules/init-package-json/default-input.js +++ b/deps/npm/node_modules/init-package-json/default-input.js @@ -38,11 +38,14 @@ 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' +exports.version = yes ? version : prompt('version', version) -exports.name = prompt('name', package.name || basename) -exports.version = prompt('version', package.version || config.get('init.version') || '1.0.0') if (!package.description) { - exports.description = prompt('description') + exports.description = yes ? '' : prompt('description') } if (!package.main) { @@ -63,7 +66,8 @@ if (!package.main) { else f = f[0] - return cb(null, prompt('entry point', f || 'index.js')) + var index = f || 'index.js' + return cb(null, yes ? index : prompt('entry point', index)) }) } } @@ -121,26 +125,32 @@ function setupScripts (d, cb) { function tx (test) { return test || notest } - if (!s.test || s.test === notest) { - if (d.indexOf('tap') !== -1) - s.test = prompt('test command', 'tap test/*.js', tx) - else if (d.indexOf('expresso') !== -1) - s.test = prompt('test command', 'expresso test', tx) - else if (d.indexOf('mocha') !== -1) - s.test = prompt('test command', 'mocha', tx) - else - s.test = prompt('test command', tx) + var commands = { + 'tap':'tap test/*.js' + , 'expresso':'expresso test' + , 'mocha':'mocha' + } + var command + Object.keys(commands).forEach(function (k) { + if (d.indexOf(k) !== -1) command = commands[k] + }) + var ps = 'test command' + if (yes) { + s.test = command || notest + } else { + s.test = command ? prompt(ps, command, tx) : prompt(ps, tx) + } } - return cb(null, s) } if (!package.repository) { exports.repository = function (cb) { fs.readFile('.git/config', 'utf8', function (er, gconf) { - if (er || !gconf) return cb(null, prompt('git repository')) - + if (er || !gconf) { + return cb(null, yes ? '' : prompt('git repository')) + } gconf = gconf.split(/\r?\n/) var i = gconf.indexOf('[remote "origin"]') if (i !== -1) { @@ -152,13 +162,13 @@ if (!package.repository) { if (u && u.match(/^git@github.com:/)) u = u.replace(/^git@github.com:/, 'https://github.com/') - return cb(null, prompt('git repository', u)) + return cb(null, yes ? u : prompt('git repository', u)) }) } } if (!package.keywords) { - exports.keywords = prompt('keywords', function (s) { + exports.keywords = yes ? '' : prompt('keywords', function (s) { if (!s) return undefined if (Array.isArray(s)) s = s.join(' ') if (typeof s !== 'string') return s @@ -167,15 +177,14 @@ if (!package.keywords) { } if (!package.author) { - exports.author = config.get('init.author.name') + exports.author = 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'), + "email" : config.get('init-author-email'), + "url" : config.get('init-author-url') } : prompt('author') } -exports.license = prompt('license', package.license || - config.get('init.license') || - 'ISC') +var license = package.license || config.get('init-license') || 'ISC' +exports.license = yes ? license : prompt('license', license) |