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

View File

@ -1,6 +1,15 @@
import { Task } from '..';
import { Task } from '../tasks/task';
import chalk from 'chalk';
export const execTask = async <T>(taskName, options?: T) => {
const task = await import(`${__dirname}/../tasks/${taskName}.ts`);
return task.default(options) as Task<T>;
export const execTask = <TOptions>(task: Task<TOptions>) => async (options: TOptions) => {
console.log(chalk.yellow(`Running ${chalk.bold(task.name)} task`));
task.setOptions(options);
try {
console.group();
await task.exec();
console.groupEnd();
} catch (e) {
console.log(e);
process.exit(1);
}
};