packages/cli: lint fixes

This commit is contained in:
Patrik Oldsberg
2020-02-28 09:18:07 +01:00
parent 09b81b2fcf
commit 6d8b4f90de
4 changed files with 6 additions and 7 deletions
@@ -5,7 +5,7 @@ export default async () => {
try {
await startDevServer();
} catch (error) {
console.error(chalk.red(error.message));
process.stderr.write(`${chalk.red(error.message)}\n`);
process.exit(1);
}
};
@@ -43,7 +43,7 @@ export default async (_command: any, args: string[]) => {
// We lazily watch all our deps, as in we don't start the actual watch compiler until a change is detected
await startWatchers(allDeps, WATCH_LOCATIONS, pkg => {
startCompiler(pkg, logFactory(pkg.name)).promise.catch(error => {
console.error(error);
process.stderr.write(`${error}\n`);
});
});
@@ -8,11 +8,9 @@ export type ColorFunc = (msg: string) => string;
// Logger utility that prefixes logs and removes terminal clear commands
export function createLogger(prefix: string = ''): Logger {
const write = (stream: NodeJS.WriteStream, msg: string) => {
if (msg.startsWith('\x1b\x63')) {
msg = msg.slice(2);
}
const str = msg.trimRight().replace(/^/gm, prefix) + '\n';
stream.write(str, 'utf8');
const noClearMsg = msg.startsWith('\x1b\x63') ? msg.slice(2) : msg;
const prefixedMsg = noClearMsg.trimRight().replace(/^/gm, prefix);
stream.write(`${prefixedMsg}\n`, 'utf8');
};
return {
+1
View File
@@ -24,6 +24,7 @@ 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(' '),