Skip to content

Commit

Permalink
feat(tasks): adds raises task
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Feb 17, 2021
1 parent 3e88259 commit f3f0c5d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/tasks/create/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export * from './clear';
export * from './exec';
export * from './log';
export * from './print';
export * from './raises';
export * from './sleep';
8 changes: 8 additions & 0 deletions src/tasks/create/raises.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Task, Context } from '../../definitions';
import { UnaryFn } from 'type-core';

export function raises(error: Error | UnaryFn<Context, Error>): Task.Sync {
return (ctx: Context): void => {
throw typeof error === 'function' ? error(ctx) : error;
};
}

0 comments on commit f3f0c5d

Please sign in to comment.