File size: 1,021 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import { eraseLine } from 'ansi-escapes';
import chalk from 'chalk';
import ora from 'ora';
// This was copied from Razzle. Lots of unused stuff.
export const info = (msg: string) => {
console.log(`${chalk.gray('>')} ${msg}`);
};
export const error = (msg: string | Error) => {
if (msg instanceof Error) {
msg = msg.message;
}
console.error(`${chalk.red('> Error!')} ${msg}`);
};
export const success = (msg: string) => {
console.log(`${chalk.green('> Success!')} ${msg}`);
};
export const wait = (msg: string) => {
const spinner = ora(chalk.green(msg));
spinner.color = 'blue';
spinner.start();
return () => {
spinner.stop();
process.stdout.write(eraseLine);
};
};
export const cmd = (cmd: string) => {
return chalk.bold(chalk.cyan(cmd));
};
export const code = (cmd: string) => {
return `${chalk.gray('`')}${chalk.bold(cmd)}${chalk.gray('`')}`;
};
export const param = (param: string) => {
return chalk.bold(`${chalk.gray('{')}${chalk.bold(param)}${chalk.gray('}')}`);
};
|