summaryrefslogtreecommitdiff
path: root/utils/run.ts
diff options
context:
space:
mode:
authorElizabeth Hunt <lizhunt@amazon.com>2025-05-13 18:58:45 -0700
committerElizabeth Hunt <lizhunt@amazon.com>2025-05-13 18:58:54 -0700
commit1d66a0f58e4ebcdf4f42c9d78f82a1ab49a2cf11 (patch)
tree07073c060b61688e4635fd4658315cc683589d3d /utils/run.ts
parent2543ac8b11af11f034836591046cdb52911f9403 (diff)
downloadci-1d66a0f58e4ebcdf4f42c9d78f82a1ab49a2cf11.tar.gz
ci-1d66a0f58e4ebcdf4f42c9d78f82a1ab49a2cf11.zip
snapshot!
Diffstat (limited to 'utils/run.ts')
-rw-r--r--utils/run.ts40
1 files changed, 0 insertions, 40 deletions
diff --git a/utils/run.ts b/utils/run.ts
deleted file mode 100644
index 9093863..0000000
--- a/utils/run.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { Either, type Traceable } from "./mod.ts";
-
-export class ProcessError extends Error {}
-export const getStdout = async (
- { 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,
- stdout: "piped",
- stderr: "piped",
- ...options,
- });
-
- try {
- const { code, stdout, stderr } = await command.output();
- const stdoutText = new TextDecoder().decode(stdout);
- 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);
- }
- throw new Error("unknown error " + e);
- }
-};