summaryrefslogtreecommitdiff
path: root/u/process/run.ts
diff options
context:
space:
mode:
Diffstat (limited to 'u/process/run.ts')
-rw-r--r--u/process/run.ts31
1 files changed, 15 insertions, 16 deletions
diff --git a/u/process/run.ts b/u/process/run.ts
index 4954438..8004f75 100644
--- a/u/process/run.ts
+++ b/u/process/run.ts
@@ -17,11 +17,12 @@ export const getStdout = <Trace>(
c: ITraceable<Command, Trace>,
options: Deno.CommandOptions = {},
): Promise<IEither<Error, string>> =>
- c.bimap(TraceUtil.withFunctionTrace(getStdout))
+ c
+ .bimap(TraceUtil.withFunctionTrace(getStdout))
.map((tCmd) => {
const cmd = tCmd.get();
tCmd.trace.trace(`:> im gonna run this command! ${cmd}`);
- const [exec, ...args] = (typeof cmd === "string") ? cmd.split(" ") : cmd;
+ const [exec, ...args] = typeof cmd === "string" ? cmd.split(" ") : cmd;
return new Deno.Command(exec, {
args,
stdout: "piped",
@@ -30,35 +31,33 @@ export const getStdout = <Trace>(
}).output();
})
.map((tOut) =>
- Either.fromFailableAsync<Error, Deno.CommandOutput>(tOut.get())
+ Either.fromFailableAsync<Error, Deno.CommandOutput>(tOut.get()),
)
.map(
TraceUtil.promiseify((tEitherOut) =>
tEitherOut.get().flatMap(({ code, stderr, stdout }) =>
- Either
- .fromFailable<Error, CommandOutputDecoded>(() => {
- const stdoutText = new TextDecoder().decode(stdout);
- const stderrText = new TextDecoder().decode(stderr);
- return { code, stdoutText, stderrText };
- })
+ Either.fromFailable<Error, CommandOutputDecoded>(() => {
+ const stdoutText = new TextDecoder().decode(stdout);
+ const stderrText = new TextDecoder().decode(stderr);
+ return { code, stdoutText, stderrText };
+ })
.mapLeft((e) => {
tEitherOut.trace.addTrace(LogLevel.ERROR).trace(`o.o wat ${e}`);
return new Error(`${e}`);
})
.flatMap((decodedOutput): Either<Error, string> => {
const { code, stdoutText, stderrText } = decodedOutput;
- tEitherOut.trace.addTrace(LogLevel.DEBUG).trace(
- `stderr hehehe ${stderrText}`,
- );
+ tEitherOut.trace
+ .addTrace(LogLevel.DEBUG)
+ .trace(`stderr hehehe ${stderrText}`);
if (code !== 0) {
- const msg =
- `i weceived an exit code of ${code} i wanna zewoooo :<`;
+ const msg = `i weceived an exit code of ${code} i wanna zewoooo :<`;
tEitherOut.trace.addTrace(LogLevel.ERROR).trace(msg);
return Either.left(new Error(msg));
}
return Either.right(stdoutText);
- })
- )
+ }),
+ ),
),
)
.get();