summaryrefslogtreecommitdiff
path: root/node/src/process.ts
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-07-15 22:09:58 +0200
committerAylur <[email protected]>2024-07-15 22:09:58 +0200
commite5251d23f158c7cc092121c3a7cc0438a73746ec (patch)
treedbd972adfb768e5600ca15f779b4cffc666a442f /node/src/process.ts
parentbe163b310398ad7f454d3ece574a476abfa216e9 (diff)
remove python and node
I have no desire to work on the python version The node version has the issue of promises not working which makes it unusable but gjs works just as good if not better. Might look back into node later
Diffstat (limited to 'node/src/process.ts')
-rw-r--r--node/src/process.ts68
1 files changed, 0 insertions, 68 deletions
diff --git a/node/src/process.ts b/node/src/process.ts
deleted file mode 100644
index 604e142..0000000
--- a/node/src/process.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-import { Astal } from "./imports.js"
-
-type Process = ReturnType<typeof Astal.Process.subprocess>
-
-type Args<Out = void, Err = void> = {
- cmd: string | string[],
- out?: (stdout: string) => Out,
- err?: (stderr: string) => Err,
-}
-
-export function args<O, E>(argsOrCmd: Args | string | string[], onOut: O, onErr: E) {
- const params = Array.isArray(argsOrCmd) || typeof argsOrCmd === "string"
- return {
- cmd: params ? argsOrCmd : argsOrCmd.cmd,
- err: params ? onErr : argsOrCmd.err || onErr,
- out: params ? onOut : argsOrCmd.out || onOut,
- }
-}
-
-export function subprocess(args: Args): Process
-export function subprocess(
- cmd: string | string[],
- onOut?: (stdout: string) => void,
- onErr?: (stderr: string) => void,
-): Process
-export function subprocess(
- argsOrCmd: Args | string | string[],
- onOut: (stdout: string) => void = console.log,
- onErr: (stderr: string) => void = console.error,
-) {
- const { cmd, err, out } = args(argsOrCmd, onOut, onErr)
- const proc = Array.isArray(cmd)
- ? Astal.Process.subprocessv(cmd)
- : Astal.Process.subprocess(cmd)
-
- proc.connect("stdout", (_: any, stdout: string) => out(stdout))
- proc.connect("stderr", (_: any, stderr: string) => err(stderr))
- return proc
-}
-
-export function exec<Out = string, Err = string>(
- args: Args<Out, Err>
-): Out | Err
-export function exec<Out = string, Err = string>(
- cmd: string | string[],
- onOut?: (stdout: string) => Out,
- onErr?: (stderr: string) => Err,
-): Out | Err
-export function exec<Out = string, Err = string>(
- argsOrCmd: Args<Out, Err> | string | string[],
- onOut: (stdout: string) => Out = out => out as Out,
- onErr: (stderr: string) => Err = out => out as Err,
-): Out | Err {
- const { cmd, err, out } = args(argsOrCmd, onOut, onErr)
- return Array.isArray(cmd)
- ? out(Astal.Process.execv(cmd)!) as Out
- : err(Astal.Process.exec(cmd)!) as Err
-}
-
-export function execAsync(cmd: string | string[]): Promise<string> {
- const proc = Array.isArray(cmd)
- ? Astal.Process.execAsyncv(cmd)
- : Astal.Process.execAsync(cmd)
- return new Promise((resolve, reject) => {
- proc.connect("stdout", (_: any, out: string) => resolve(out))
- proc.connect("stderr", (_: any, err: string) => reject(err))
- })
-}