summaryrefslogtreecommitdiff
path: root/u/process
diff options
context:
space:
mode:
Diffstat (limited to 'u/process')
-rw-r--r--u/process/env.ts9
-rw-r--r--u/process/run.ts18
2 files changed, 17 insertions, 10 deletions
diff --git a/u/process/env.ts b/u/process/env.ts
index 470cb39..5ba4189 100644
--- a/u/process/env.ts
+++ b/u/process/env.ts
@@ -1,10 +1,13 @@
import { Either, type IEither } from "@emprespresso/pengueno";
export const getRequiredEnv = <V extends string>(name: V): IEither<Error, V> =>
- Either.fromFailable<Error, V | undefined>(() => Deno.env.get(name) as V | undefined) // could throw when no permission.
+ Either.fromFailable<Error, V | undefined>(
+ () => Deno.env.get(name) as V | undefined,
+ ) // could throw when no permission.
.flatMap(
- (v) => (v && Either.right(v)) ||
- Either.left(new Error(`environment variable "${name}" is required D:`))
+ (v) =>
+ (v && Either.right(v)) ||
+ Either.left(new Error(`environment variable "${name}" is required D:`)),
);
type ObjectFromList<T extends ReadonlyArray<string>, V = string> = {
diff --git a/u/process/run.ts b/u/process/run.ts
index 8004f75..7a74c3e 100644
--- a/u/process/run.ts
+++ b/u/process/run.ts
@@ -28,10 +28,12 @@ export const getStdout = <Trace>(
stdout: "piped",
stderr: "piped",
...options,
- }).output();
+ });
})
- .map((tOut) =>
- Either.fromFailableAsync<Error, Deno.CommandOutput>(tOut.get()),
+ .map((tCmd) =>
+ Either.fromFailableAsync<Error, Deno.CommandOutput>(() =>
+ tCmd.get().output(),
+ ),
)
.map(
TraceUtil.promiseify((tEitherOut) =>
@@ -45,11 +47,13 @@ export const getStdout = <Trace>(
tEitherOut.trace.addTrace(LogLevel.ERROR).trace(`o.o wat ${e}`);
return new Error(`${e}`);
})
- .flatMap((decodedOutput): Either<Error, string> => {
+ .flatMap((decodedOutput): IEither<Error, string> => {
const { code, stdoutText, stderrText } = decodedOutput;
- tEitherOut.trace
- .addTrace(LogLevel.DEBUG)
- .trace(`stderr hehehe ${stderrText}`);
+ if (stderrText) {
+ tEitherOut.trace
+ .addTrace(LogLevel.DEBUG)
+ .trace(`stderr: ${stderrText}`);
+ }
if (code !== 0) {
const msg = `i weceived an exit code of ${code} i wanna zewoooo :<`;
tEitherOut.trace.addTrace(LogLevel.ERROR).trace(msg);