feat: Effects that shouldn't be needed removed from utils

This commit is contained in:
BluJ
2023-06-09 10:58:29 -06:00
parent 817913c9df
commit bc80cc974a
8 changed files with 108 additions and 49 deletions

View File

@@ -1,5 +1,6 @@
import { Effects } from "../../types"
import { createUtils } from "../../util"
import { stringFromStdErrOut } from "../../util/stringFromStdErrOut"
import { CheckResult } from "./CheckResult"
export function containsAddress(x: string, port: number) {
const readPorts = x
@@ -32,10 +33,17 @@ export async function checkPortListening(
Promise.resolve().then(async () => {
const hasAddress =
containsAddress(
await utils.runCommand(`cat /proc/net/tcp`, {}),
await utils.childProcess
.exec(`cat /proc/net/tcp`, {})
.then(stringFromStdErrOut),
port,
) ||
containsAddress(await utils.runCommand("cat /proc/net/udp", {}), port)
containsAddress(
await utils.childProcess
.exec("cat /proc/net/udp", {})
.then(stringFromStdErrOut),
port,
)
if (hasAddress) {
return { status: "passing", message: options.successMessage }
}

View File

@@ -1,5 +1,6 @@
import { CommandType, Effects } from "../../types"
import { createUtils } from "../../util"
import { stringFromStdErrOut } from "../../util/stringFromStdErrOut"
import { CheckResult } from "./CheckResult"
import { timeoutPromise } from "./index"
@@ -22,7 +23,7 @@ export const runHealthScript = async (
): Promise<CheckResult> => {
const utils = createUtils(effects)
const res = await Promise.race([
utils.runCommand(runCommand, { timeout }),
utils.childProcess.exec(runCommand, { timeout }).then(stringFromStdErrOut),
timeoutPromise(timeout),
]).catch((e) => {
console.warn(errorMessage)