chore: Add in the converter for the newest of the builder.

This commit is contained in:
BluJ
2023-04-10 15:58:36 -06:00
parent 4efa94ec10
commit 0987303a0b
11 changed files with 219 additions and 187 deletions

View File

@@ -1,4 +1,4 @@
import { Effects } from "../../types";
import { CommandType, Effects } from "../../types";
import { CheckResult } from "./CheckResult";
import { timeoutPromise } from "./index";
@@ -9,18 +9,18 @@ import { timeoutPromise } from "./index";
* @param param0
* @returns
*/
export const runHealthScript = async (
export const runHealthScript = async <A extends string>(
effects: Effects,
runCommand: Parameters<Effects["runCommand"]>[0],
runCommand: CommandType<A>,
{
timeout = 30000,
errorMessage = `Error while running command: ${runCommand}`,
message = (res: string) =>
`Have ran script ${runCommand} and the result: ${res}`,
}
} = {}
): Promise<CheckResult> => {
const res = await Promise.race([
effects.runCommand(runCommand),
effects.runCommand(runCommand, { timeoutMillis: timeout }),
timeoutPromise(timeout),
]).catch((e) => {
effects.warn(errorMessage);