Minor refactor of cli tasks (core start, gui publishing)

This commit is contained in:
Dominik Prokop
2019-03-05 08:56:29 +01:00
parent cee5f030dc
commit 73ef864979
9 changed files with 219 additions and 182 deletions
+20
View File
@@ -0,0 +1,20 @@
import ora from 'ora';
type FnToSpin<T> = (options: T) => Promise<void>;
export const useSpinner = <T>(spinnerLabel: string, fn: FnToSpin<T>, killProcess = true) => {
return async (options: T) => {
const spinner = new ora(spinnerLabel);
spinner.start();
try {
await fn(options);
spinner.succeed();
} catch (e) {
spinner.fail();
console.log(e);
if (killProcess) {
process.exit(1);
}
}
};
};