prompt-for
Advanced tools
Comparing version 0.4.1 to 0.5.0
0.5.0 - October 4, 2014 | ||
----------------------- | ||
* add list support | ||
0.4.1 - May 28, 2014 | ||
@@ -3,0 +7,0 @@ -------------------- |
@@ -85,2 +85,19 @@ | ||
/** | ||
* Prompt for a list of items for a given `schema` and `options`. | ||
* | ||
* @param {Object} schema | ||
* @param {Object} options | ||
* @param {Function} fn | ||
*/ | ||
exports.list = function(schema, options, fn){ | ||
var msg = format(schema, options); | ||
prompt(msg, function(val){ | ||
var ret = val.split(/ *, */g); | ||
if (!(ret instanceof Array)) ret = []; | ||
return fn(ret); | ||
}); | ||
}; | ||
/** | ||
* Format the prompt message. | ||
@@ -87,0 +104,0 @@ * |
@@ -5,3 +5,3 @@ { | ||
"repository": "git://github.com/segmentio/prompt-for.git", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "main": "lib/index.js", |
@@ -68,2 +68,14 @@ | ||
it('should coerce lists', function(done){ | ||
prompt({ list: 'list' }, function(err, answers){ | ||
if (err) return done(err); | ||
assert(answers.list instanceof Array); | ||
assert.equal(answers.list[0], 'one'); | ||
assert.equal(answers.list[1], 'two'); | ||
assert.equal(answers.list[2], 'three'); | ||
done(); | ||
}); | ||
answer('one, two, three'); | ||
}); | ||
it('should apply defaults', function(done){ | ||
@@ -70,0 +82,0 @@ prompt({ number: { type: 'number', default: 42 }}, function(err, answers){ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
12319
326
0