mirror of
https://github.com/morten-olsen/mini-loader.git
synced 2026-02-08 01:36:26 +01:00
qa: add e2e tests
This commit is contained in:
27
packages/cli/src/api/output.ts
Normal file
27
packages/cli/src/api/output.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import ora from 'ora';
|
||||
import { Service } from 'typedi';
|
||||
|
||||
@Service()
|
||||
class Terminal {
|
||||
public log = (message: string) => {
|
||||
console.log(message);
|
||||
};
|
||||
|
||||
public output = (data: unknown) => {
|
||||
console.table(data);
|
||||
};
|
||||
|
||||
public step = async <T>(message: string, action: () => Promise<T>) => {
|
||||
const spinner = ora(message).start();
|
||||
try {
|
||||
const result = await action();
|
||||
await spinner.succeed();
|
||||
return result;
|
||||
} catch (err) {
|
||||
await spinner.fail();
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export { Terminal };
|
||||
Reference in New Issue
Block a user