diff --git a/src/modules/helpers/modifiers.ts b/src/modules/helpers/modifiers.ts index 6a1685f1..38f90aa7 100644 --- a/src/modules/helpers/modifiers.ts +++ b/src/modules/helpers/modifiers.ts @@ -2,11 +2,30 @@ import { Write } from '../../services/write.js'; import { indentation } from '../../configs/indentation.js'; import { format } from '../../services/format.js'; -export const todo = (message: string, _cb?: () => unknown) => +export function todo(message: string): void; +export async function todo( + message: string, + _cb?: () => Promise +): Promise; +export function todo(message: string, _cb?: () => unknown): void; +export async function todo( + message: string | (() => unknown) | (() => Promise), + _cb?: (() => unknown) | (() => Promise) +): Promise { Write.log( `${indentation.hasDescribe ? ' ' : ''}${format(`● ${message}`).cyan().bold()}` ); + /* c8 ignore start */ // Type guard + if (typeof _cb === 'function') { + const isAsync = _cb.constructor.name === 'AsyncFunction'; + + if (isAsync) return await Promise.resolve(); + return; + } + /* c8 ignore stop */ +} + export async function skip( message: string, _cb: () => Promise