From ced45fc57984ea479bba897cb18d1347b2f24f4a Mon Sep 17 00:00:00 2001 From: Benjamin Fischer <61995275+c4spar@users.noreply.github.com> Date: Sat, 28 Sep 2024 22:44:33 +0200 Subject: [PATCH] refactor(command): remove unused files (#751) --- command/_runtime/exit.ts | 11 ----------- command/_runtime/get-argv.ts | 6 ------ command/_runtime/get-env.ts | 12 ------------ command/_runtime/inspect.ts | 9 --------- command/_runtime/no_color.ts | 13 ------------- command/_runtime/write_sync.ts | 13 ------------- 6 files changed, 64 deletions(-) delete mode 100644 command/_runtime/exit.ts delete mode 100644 command/_runtime/get-argv.ts delete mode 100644 command/_runtime/get-env.ts delete mode 100644 command/_runtime/inspect.ts delete mode 100644 command/_runtime/no_color.ts delete mode 100644 command/_runtime/write_sync.ts diff --git a/command/_runtime/exit.ts b/command/_runtime/exit.ts deleted file mode 100644 index d6370104..00000000 --- a/command/_runtime/exit.ts +++ /dev/null @@ -1,11 +0,0 @@ -export function exit(code: number): never { - // deno-lint-ignore no-explicit-any - const { Deno, process } = globalThis as any; - const exit: (code: number) => never = Deno?.exit ?? process?.exit; - - if (exit) { - exit(code); - } - - throw new Error("unsupported runtime"); -} diff --git a/command/_runtime/get-argv.ts b/command/_runtime/get-argv.ts deleted file mode 100644 index e702d35d..00000000 --- a/command/_runtime/get-argv.ts +++ /dev/null @@ -1,6 +0,0 @@ -export function getArgv(): Array { - // deno-lint-ignore no-explicit-any - const { Deno, process } = globalThis as any; - - return Deno?.args ?? process?.argv.slice(2) ?? []; -} diff --git a/command/_runtime/get-env.ts b/command/_runtime/get-env.ts deleted file mode 100644 index 0f49b663..00000000 --- a/command/_runtime/get-env.ts +++ /dev/null @@ -1,12 +0,0 @@ -export function getEnv(name: string): string | undefined { - // deno-lint-ignore no-explicit-any - const { Deno, process } = globalThis as any; - - if (Deno) { - return Deno.env.get(name); - } else if (process) { - return process.env[name]; - } - - throw new Error("unsupported runtime"); -} diff --git a/command/_runtime/inspect.ts b/command/_runtime/inspect.ts deleted file mode 100644 index dd5d6dde..00000000 --- a/command/_runtime/inspect.ts +++ /dev/null @@ -1,9 +0,0 @@ -export function inspect(value: unknown, colors: boolean): string { - // deno-lint-ignore no-explicit-any - const { Deno } = globalThis as any; - - return Deno?.inspect( - value, - { depth: 1, colors, trailingComma: false }, - ) ?? JSON.stringify(value, null, 2); -} diff --git a/command/_runtime/no_color.ts b/command/_runtime/no_color.ts deleted file mode 100644 index 51433280..00000000 --- a/command/_runtime/no_color.ts +++ /dev/null @@ -1,13 +0,0 @@ -export function getNoColor(): boolean { - // deno-lint-ignore no-explicit-any - const { Deno, process } = globalThis as any; - - if (Deno) { - return Deno.noColor; - } else if (process) { - return process?.env.NO_COLOR === "1" || - process?.env.NODE_DISABLE_COLORS === "1"; - } - - throw new Error("unsupported runtime"); -} diff --git a/command/_runtime/write_sync.ts b/command/_runtime/write_sync.ts deleted file mode 100644 index f46d6962..00000000 --- a/command/_runtime/write_sync.ts +++ /dev/null @@ -1,13 +0,0 @@ -export function writeSync(data: Uint8Array): number { - // deno-lint-ignore no-explicit-any - const { Deno, process } = globalThis as any; - - if (Deno) { - return Deno.stdout.writeSync(data); - } else if (process) { - process.stdout.write(data); - return data.byteLength; - } else { - throw new Error("unsupported runtime"); - } -}