mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-08 14:41:28 -07:00
20 lines
439 B
TypeScript
20 lines
439 B
TypeScript
import type { ProcessOutput } from 'zx'
|
|
|
|
export function onProcSuccess(
|
|
name: string,
|
|
resolve: (value: unknown) => void,
|
|
reject: (reason?: unknown) => void
|
|
) {
|
|
return (proc: ProcessOutput) => {
|
|
if (proc.exitCode === 0) {
|
|
resolve(`${name} ran correctly`)
|
|
} else {
|
|
reject(`${name} exited with ${proc.exitCode}`)
|
|
}
|
|
}
|
|
}
|
|
|
|
export function catchError(reject: (reason?: unknown) => void) {
|
|
return () => reject('unknown error')
|
|
}
|