Comparing version 0.1.7 to 0.1.8
@@ -14,3 +14,3 @@ #!/usr/bin/env node | ||
var name = "ask-json"; | ||
var version = "0.1.7"; | ||
var version = "0.1.8"; | ||
@@ -17,0 +17,0 @@ var ensureFile = (filePath) => { |
@@ -9,6 +9,7 @@ 'use strict'; | ||
var get = _interopDefault(require('lodash/get')); | ||
var isFunction = _interopDefault(require('lodash/isFunction')); | ||
var isString = _interopDefault(require('lodash/isString')); | ||
var prompts = _interopDefault(require('prompts')); | ||
var range = _interopDefault(require('lodash/range')); | ||
var traverseSchema = _interopDefault(require('json-schema-traverse')); | ||
var isFunction = _interopDefault(require('lodash/isFunction')); | ||
var set = _interopDefault(require('lodash/set')); | ||
@@ -57,2 +58,8 @@ var isEqual = _interopDefault(require('lodash/isEqual')); | ||
const getMessage = (customMessage, dataPath) => { | ||
if (isFunction(customMessage)) return customMessage(dataPath, get(this.data, dataPath, [])); | ||
if (isString(customMessage)) return chalkTemplate(chalk, customMessage); | ||
return chalk`Would you like to add an item to {green ${dataPath}}?`; | ||
}; | ||
traverseSchema(this.schema, { cb: findArrays }); | ||
@@ -68,3 +75,3 @@ | ||
name: 'value', | ||
message: customMessage ? chalkTemplate(chalk, customMessage) : chalk`Would you like to add an item to {green ${dataPath}}?`, | ||
message: getMessage(customMessage, dataPath), | ||
initial: false, | ||
@@ -71,0 +78,0 @@ }); |
{ | ||
"name": "ask-json", | ||
"description": "Easy interactive prompts to create and validate data using JSON schema", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"author": "Jon McClure <jon.r.mcclure@gmail.com>", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/reuters-graphics/ask-json", |
30383
639