Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/init-package-json/default-input.js')
-rw-r--r--node_modules/init-package-json/default-input.js38
1 files changed, 16 insertions, 22 deletions
diff --git a/node_modules/init-package-json/default-input.js b/node_modules/init-package-json/default-input.js
index 4110bac98..f24fa5d32 100644
--- a/node_modules/init-package-json/default-input.js
+++ b/node_modules/init-package-json/default-input.js
@@ -15,6 +15,10 @@ function niceName (n) {
return n.replace(/^node-|[.-]js$/g, '').toLowerCase()
}
+function conf (name) {
+ return config.get(name) || config.get(name.split('.').join('-'))
+}
+
function readDeps (test, excluded) { return function (cb) {
fs.readdir('node_modules', function (er, dir) {
if (er) return cb()
@@ -35,7 +39,7 @@ function readDeps (test, excluded) { return function (cb) {
if (p._requiredBy) {
if (!p._requiredBy.some(function (req) { return req === '#USER' })) return next()
}
- deps[d] = config.get('save-exact') ? p.version : config.get('save-prefix') + p.version
+ deps[d] = conf('save.exact') ? p.version : conf('save.prefix') + p.version
return next()
})
})
@@ -47,7 +51,7 @@ function readDeps (test, excluded) { return function (cb) {
var name = package.name || basename
var spec = npa(name)
-var scope = config.get('scope')
+var scope = conf('scope')
if (scope) {
if (scope.charAt(0) !== '@') scope = '@' + scope
if (spec.scope) {
@@ -56,7 +60,7 @@ if (scope) {
name = scope + '/' + name
}
}
-exports.name = yes ? name : prompt('name', name, function (data) {
+exports.name = yes ? name : prompt('package name', niceName(name), function (data) {
var its = validateName(data)
if (its.validForNewPackages) return data
var errors = (its.errors || []).concat(its.warnings || [])
@@ -65,10 +69,7 @@ exports.name = yes ? name : prompt('name', name, function (data) {
return er
})
-var version = package.version ||
- config.get('init.version') ||
- config.get('init-version') ||
- '1.0.0'
+var version = package.version || conf('init.version') || '1.0.0'
exports.version = yes ?
version :
prompt('version', version, function (version) {
@@ -129,6 +130,7 @@ exports.directories = function (cb) {
case 'test': case 'tests': return res.test = d
case 'doc': case 'docs': return res.doc = d
case 'man': return res.man = d
+ case 'lib': return res.lib = d
}
})
if (Object.keys(res).length === 0) res = undefined
@@ -211,23 +213,15 @@ if (!package.keywords) {
}
if (!package.author) {
- exports.author = config.get('init.author.name') ||
- config.get('init-author-name')
- ? {
- "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')
- }
- : yes ? '' : prompt('author')
+ var a = conf('init.author.name')
+ exports.author = a ? {
+ "name": a,
+ "email": conf('init.author.email'),
+ "url": conf('init.author.url')
+ } : yes ? '' : prompt('author')
}
-var license = package.license ||
- config.get('init.license') ||
- config.get('init-license') ||
- 'ISC'
+var license = package.license || conf('init.license') || 'ISC'
exports.license = yes ? license : prompt('license', license, function (data) {
var its = validateLicense(data)
if (its.validForNewPackages) return data