wrapCliTask
Wraps a CLI task function to ensure it runs safely and handles its CliTaskResult.
Honors the per-script off switch first: when the npm script currently running has been switched off — LINT_MD=0 npm run lint:md, see getDisabledScriptEnvVariableName — the task is not executed and the process exits successfully. Because every scripts/*.ts entry point already funnels through here, no script has to opt in, and each npm run sub-step of a composite script (e.g. build) carries its own switch.
Import:
import { wrapCliTask } from 'obsidian-dev-utils/script-utils/cli-utils';Signature:
function wrapCliTask(taskFunction: () => Promisable<MaybeReturn<CliTaskResult>>): Promise<void>Parameters:
| Parameter | Type | Description |
|---|---|---|
taskFunction | () => Promisable<MaybeReturn<CliTaskResult>> | The task function to execute, which may return a CliTaskResult or void. |
Returns: Promise<void> — A Promise that resolves when the task is completed and exits with the appropriate status.