cli: display create prompt messages in blue and errors in red

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-11-12 11:28:54 +01:00
parent 55e58c5568
commit 3ca0d3368e
+17 -1
View File
@@ -14,6 +14,7 @@
* limitations under the License.
*/
import chalk from 'chalk';
import inquirer from 'inquirer';
import { AnyFactory } from './types';
import * as factories from './factories';
@@ -80,7 +81,22 @@ export class FactoryRegistry {
}
}
currentOptions = await inquirer.prompt(needsAnswers, currentOptions);
currentOptions = await inquirer.prompt(
needsAnswers.map(option => ({
...option,
message: option.message && chalk.blue(option.message),
validate:
option.validate &&
(async (...args) => {
const result = await option.validate!(...args);
if (typeof result === 'string') {
return chalk.red(result);
}
return result;
}),
})),
currentOptions,
);
}
return currentOptions;