diff --git a/src/tasks/create/index.ts b/src/tasks/create/index.ts index 9afb1c4..49939b9 100644 --- a/src/tasks/create/index.ts +++ b/src/tasks/create/index.ts @@ -2,4 +2,5 @@ export * from './clear'; export * from './exec'; export * from './log'; export * from './print'; +export * from './raises'; export * from './sleep'; diff --git a/src/tasks/create/raises.ts b/src/tasks/create/raises.ts new file mode 100644 index 0000000..31f2b96 --- /dev/null +++ b/src/tasks/create/raises.ts @@ -0,0 +1,8 @@ +import { Task, Context } from '../../definitions'; +import { UnaryFn } from 'type-core'; + +export function raises(error: Error | UnaryFn): Task.Sync { + return (ctx: Context): void => { + throw typeof error === 'function' ? error(ctx) : error; + }; +}