Skip to content

Commit 9c183b4

Browse files
committed
use prompts instead of schema
1 parent c5275b8 commit 9c183b4

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

lib/ask.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ var promptMapping = {
1111
/**
1212
* Ask questions, return results.
1313
*
14-
* @param {Object} schema
14+
* @param {Object} prompts
1515
* @param {Object} data
1616
* @param {Function} done
1717
*/
1818

19-
module.exports = function ask (schema, data, done) {
20-
async.eachSeries(Object.keys(schema), function (key, next) {
21-
prompt(data, key, schema[key], next)
19+
module.exports = function ask (prompts, data, done) {
20+
async.eachSeries(Object.keys(prompts), function (key, next) {
21+
prompt(data, key, prompts[key], next)
2222
}, done)
2323
}
2424

lib/generate.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = function generate (name, src, dest, done) {
3636
// avoid handlebars escaping HTML
3737
data.noEscape = true
3838
metalsmith
39-
.use(askQuestions(opts.schema))
39+
.use(askQuestions(opts.prompts))
4040
.use(filterFiles(opts.filters))
4141
.use(renderTemplateFiles)
4242
.clean(false)
@@ -56,13 +56,13 @@ module.exports = function generate (name, src, dest, done) {
5656
/**
5757
* Create a middleware for asking questions.
5858
*
59-
* @param {Object} schema
59+
* @param {Object} prompts
6060
* @return {Function}
6161
*/
6262

63-
function askQuestions (schema) {
63+
function askQuestions (prompts) {
6464
return function (files, metalsmith, done) {
65-
ask(schema, metalsmith.metadata(), done)
65+
ask(prompts, metalsmith.metadata(), done)
6666
}
6767
}
6868

lib/options.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,25 @@ module.exports = function options (name, dir) {
2727
}
2828

2929
/**
30-
* Set the default value for a schema key
30+
* Set the default value for a prompt question
3131
*
3232
* @param {Object} opts
3333
* @param {String} key
3434
* @param {String} val
3535
*/
3636

3737
function setDefault (opts, key, val) {
38-
var schema = opts.schema || (opts.schema = {})
39-
if (!schema[key] || typeof schema[key] !== 'object') {
40-
schema[key] = {
38+
if (opts.schema) {
39+
opts.prompts = opts.schema
40+
delete opts.schema
41+
}
42+
var prompts = opts.prompts || (opts.prompts = {})
43+
if (!prompts[key] || typeof prompts[key] !== 'object') {
44+
prompts[key] = {
4145
'type': 'string',
4246
'default': val
4347
}
4448
} else {
45-
schema[key]['default'] = val
49+
prompts[key]['default'] = val
4650
}
4751
}

0 commit comments

Comments
 (0)