@trenskow/reader 0.1.85 → 0.1.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/interview.js +14 -1
- package/package.json +1 -1
package/lib/interview.js
CHANGED
|
@@ -124,7 +124,20 @@ const interview = async (schema, {
|
|
|
124
124
|
|
|
125
125
|
initial = undefined;
|
|
126
126
|
|
|
127
|
-
return await (await isvalid())(answer, schema
|
|
127
|
+
return await (await isvalid())(answer, schema, {
|
|
128
|
+
defaults: {
|
|
129
|
+
pre: (data, schema) => {
|
|
130
|
+
|
|
131
|
+
if (schema.type !== Boolean) return data;
|
|
132
|
+
|
|
133
|
+
if (['yes', 'y', 'true', '1'].includes(String(data).toLowerCase())) return true;
|
|
134
|
+
if (['no', 'n', 'false', '0'].includes(String(data).toLowerCase())) return false;
|
|
135
|
+
|
|
136
|
+
return data;
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
128
141
|
|
|
129
142
|
} catch (error) {
|
|
130
143
|
print.err.bold(error.message);
|