Add chalked output to main

This commit is contained in:
Marcus Eide
2020-03-03 10:12:18 +01:00
parent fbc8befca6
commit 39cd481040
+10 -4
View File
@@ -1,4 +1,5 @@
import program from 'commander';
import chalk from 'chalk';
import createPluginCommand from './commands/createPlugin';
import watch from './commands/watch-deps';
import serve from './commands/serve';
@@ -24,14 +25,19 @@ const main = (argv: string[]) => {
.action(watch);
program.on('command:*', () => {
// eslint-disable-next-line no-console
console.error(
'Invalid command: %s\nSee --help for a list of available commands.',
program.args.join(' '),
console.log();
console.log(
chalk.red(`Invalid command: ${chalk.cyan(program.args.join(' '))}`),
);
console.log(chalk.red('See --help for a list of available commands.'));
console.log();
process.exit(1);
});
if (!process.argv.slice(2).length) {
program.outputHelp(chalk.yellow);
}
program.parse(argv);
};