diff --git a/src/cli/index.ts b/src/cli/index.ts index a20b485..7fbe258 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -37,9 +37,7 @@ async function mainWorker(d: D) { const herebyfilePath = path.resolve(d.cwd(), args.herebyfile ?? findHerebyfile(d.cwd())); - if (await reexec(herebyfilePath)) { - return; - } + if (await reexec(herebyfilePath)) return; if (args.version) { d.log(`hereby ${d.version()}`); @@ -85,12 +83,10 @@ export async function selectTasks( taskNames: string[], ): Promise { if (taskNames.length === 0) { - if (!herebyfile.defaultTask) { - throw new UserError( - `No default task has been exported from ${d.simplifyPath(herebyfilePath)}; please specify a task name.`, - ); - } - return [herebyfile.defaultTask]; + if (herebyfile.defaultTask) return [herebyfile.defaultTask]; + throw new UserError( + `No default task has been exported from ${d.simplifyPath(herebyfilePath)}; please specify a task name.`, + ); } const tasks: Task[] = []; diff --git a/src/cli/loadHerebyfile.ts b/src/cli/loadHerebyfile.ts index 0b79380..c030ec5 100644 --- a/src/cli/loadHerebyfile.ts +++ b/src/cli/loadHerebyfile.ts @@ -50,14 +50,14 @@ export async function loadHerebyfile(herebyfilePath: string): Promise) { function checkTaskInvariantsWorker(tasks: Iterable) { for (const task of tasks) { - if (checkedTasks.has(task)) { - continue; - } + if (checkedTasks.has(task)) continue; if (taskStack.has(task)) { throw new UserError(`Task "${pc.blue(task.options.name)}" references itself.`); diff --git a/src/cli/runner.ts b/src/cli/runner.ts index 0db05e0..eb75b92 100644 --- a/src/cli/runner.ts +++ b/src/cli/runner.ts @@ -22,9 +22,7 @@ export class Runner { const results = await Promise.allSettled( tasks.map((task) => { const cached = this._addedTasks.get(task); - if (cached) { - return cached; - } + if (cached) return cached; const promise = this._runTask(task); this._addedTasks.set(task, promise); @@ -45,9 +43,7 @@ export class Runner { await this.runTasks(...dependencies); } - if (!run) { - return; - } + if (!run) return; try { this.onTaskStart(task); @@ -62,26 +58,20 @@ export class Runner { protected onTaskStart(task: Task): void { this._startTimes.set(task, performance.now()); - if (this._errored) { - return; // Skip logging. - } + if (this._errored) return; // Skip logging. this._d.log(`Starting ${pc.blue(task.options.name)}`); } protected onTaskFinish(task: Task): void { - if (this._errored) { - return; // Skip logging. - } + if (this._errored) return; // Skip logging. const took = performance.now() - this._startTimes.get(task)!; this._d.log(`Finished ${pc.green(task.options.name)} in ${this._d.prettyMilliseconds(took)}`); } protected onTaskError(task: Task, e: unknown): void { - if (this._errored) { - return; // Skip logging. - } + if (this._errored) return; // Skip logging. this._errored = true; const took = performance.now() - this._startTimes.get(task)!;