summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/init-package-json/default-input.js
diff options
context:
space:
mode:
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.js25
1 files changed, 20 insertions, 5 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 95c799ebb..3af2f62af 100644
--- a/deps/npm/node_modules/init-package-json/default-input.js
+++ b/deps/npm/node_modules/init-package-json/default-input.js
@@ -1,6 +1,8 @@
var fs = require('fs')
-var path = require('path')
var glob = require('glob')
+var path = require('path')
+var validateName = require('validate-npm-package-name')
+var npa = require('npm-package-arg')
// more popular packages should go here, maybe?
function isTestPkg (p) {
@@ -39,10 +41,23 @@ function readDeps (test) { return function (cb) {
}}
var name = package.name || basename
-if (config.get('scope')) {
- name = '@' + config.get('scope') + '/' + name
+var spec = npa(name)
+var scope = config.get('scope')
+if (scope) {
+ if (scope.charAt(0) !== '@') scope = '@' + scope
+ if (spec.scope) {
+ name = scope + '/' + spec.name.split('/')[1]
+ } else {
+ name = scope + '/' + name
+ }
}
-exports.name = yes ? name : prompt('name', name)
+exports.name = yes ? name : prompt('name', name, function (data) {
+ var its = validateName(data)
+ if (its.validForNewPackages) return data
+ var er = new Error('Sorry, ' + its.errors.join(' and ') + '.')
+ er.notValid = true
+ return er
+})
var version = package.version ||
config.get('init.version') ||
@@ -193,7 +208,7 @@ if (!package.author) {
"url" : config.get('init.author.url') ||
config.get('init-author-url')
}
- : prompt('author')
+ : yes ? '' : prompt('author')
}
var license = package.license ||