summaryrefslogtreecommitdiff
path: root/utils/run.ts
diff options
context:
space:
mode:
Diffstat (limited to 'utils/run.ts')
-rw-r--r--utils/run.ts11
1 files changed, 9 insertions, 2 deletions
diff --git a/utils/run.ts b/utils/run.ts
index 06e7d9f..9093863 100644
--- a/utils/run.ts
+++ b/utils/run.ts
@@ -1,10 +1,13 @@
-import { Either } from "./mod.ts";
+import { Either, type Traceable } from "./mod.ts";
export class ProcessError extends Error {}
export const getStdout = async (
- cmd: string[] | string,
+ { item: cmd, logger: _logger }: Traceable<string[] | string>,
options: Deno.CommandOptions = {},
): Promise<Either<ProcessError, string>> => {
+ const logger = _logger.addTracer(() => "[getStdout]");
+
+ logger.log(`:> im gonna run this command!`, cmd);
const [exec, ...args] = (typeof cmd === "string") ? cmd.split(" ") : cmd;
const command = new Deno.Command(exec, {
args,
@@ -19,12 +22,16 @@ export const getStdout = async (
const stderrText = new TextDecoder().decode(stderr);
if (code !== 0) {
+ logger.error(`i weceived an exit code of ${code} i wanna zeroooo :<`);
return Either.left<ProcessError, string>(
new ProcessError(`command failed\n${stderrText}`),
);
}
+
+ logger.log("yay! i got code 0 :3", cmd);
return Either.right<ProcessError, string>(stdoutText);
} catch (e) {
+ logger.error(`o.o wat`, e);
if (e instanceof Error) {
return Either.left<ProcessError, string>(e);
}