From 48547961683ff2861e83a9cea3858775c5a27180 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Wed, 1 Nov 2023 15:27:31 -0400 Subject: [PATCH] Make code formatting more consistent --- src/bun/ffi.ts | 9 ++++----- src/bun/index.ts | 6 +++--- src/common/index.ts | 2 +- src/common/termios.ts | 9 +++++---- src/deno/ffi.ts | 2 +- src/deno/index.ts | 6 +++--- src/scroll.ts | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/bun/ffi.ts b/src/bun/ffi.ts index 38eda62..3f0b2dc 100644 --- a/src/bun/ffi.ts +++ b/src/bun/ffi.ts @@ -1,7 +1,7 @@ /** * This is all the nasty ffi setup for the bun runtime */ -import { dlopen, ptr, suffix } from "bun:ffi"; +import { dlopen, ptr, suffix } from 'bun:ffi'; const getLib = (name: string) => { return dlopen( @@ -21,17 +21,16 @@ const getLib = (name: string) => { }, }, ); -} +}; -let cStdLib = {symbols: {}}; +let cStdLib = { symbols: {} }; try { cStdLib = getLib(`libc.${suffix}`); } catch { try { cStdLib = getLib(`libc.${suffix}.6`); - } - catch { + } catch { throw new Error('Could not find c standard library'); } } diff --git a/src/bun/index.ts b/src/bun/index.ts index 67daabc..b8a8627 100644 --- a/src/bun/index.ts +++ b/src/bun/index.ts @@ -2,7 +2,7 @@ * The main entrypoint when using Bun as the runtime */ -import { getTermios } from "../common/termios"; +import { getTermios } from '../common/termios'; export async function main(): Promise { const t = await getTermios(); @@ -18,10 +18,10 @@ export async function main(): Promise { } } - process.on("exit", (code) => { + process.on('exit', (code) => { console.log(`Process exited with code ${code}`); t.disableRawMode(); }); return -1; -} \ No newline at end of file +} diff --git a/src/common/index.ts b/src/common/index.ts index d2a252f..bcd538c 100644 --- a/src/common/index.ts +++ b/src/common/index.ts @@ -41,4 +41,4 @@ export const importForRuntime = async (path: string) => { const importPath = base + cleanedPath + suffix; return await import(importPath); -} \ No newline at end of file +}; diff --git a/src/common/termios.ts b/src/common/termios.ts index 3228ce8..a64c48f 100644 --- a/src/common/termios.ts +++ b/src/common/termios.ts @@ -1,4 +1,4 @@ -import { importForRuntime } from "./index.ts"; +import { importForRuntime } from './index.ts'; export const STDIN_FILENO = 0; export const STOUT_FILENO = 1; @@ -29,7 +29,8 @@ export interface ITermios { export const getTermios = async () => { // Get the runtime-specific ffi wrappers - const { tcgetattr, tcsetattr, cfmakeraw, getPointer } = await importForRuntime('ffi'); + const { tcgetattr, tcsetattr, cfmakeraw, getPointer } = + await importForRuntime('ffi'); /** * Implementation to toggle raw mode with Bun runtime @@ -39,7 +40,7 @@ export const getTermios = async () => { * Are we in raw mode? * @private */ - #inRawMode:boolean; + #inRawMode: boolean; /** * The saved version of the termios struct for cooked/canonical mode @@ -110,4 +111,4 @@ export const getTermios = async () => { } return new Termios(); -} \ No newline at end of file +}; diff --git a/src/deno/ffi.ts b/src/deno/ffi.ts index 703868a..d0c9eca 100644 --- a/src/deno/ffi.ts +++ b/src/deno/ffi.ts @@ -36,6 +36,6 @@ const cStdLib = Deno.dlopen( } as const, ); -export const { tcgetattr, tcsetattr, cfmakeraw} = cStdLib.symbols; +export const { tcgetattr, tcsetattr, cfmakeraw } = cStdLib.symbols; export const getPointer = Deno.UnsafePointer.of; diff --git a/src/deno/index.ts b/src/deno/index.ts index 9dacf97..6e844d5 100644 --- a/src/deno/index.ts +++ b/src/deno/index.ts @@ -1,10 +1,10 @@ /** * The main entrypoint when using Deno as the runtime */ -import {getTermios} from "../common/termios.ts"; +import { getTermios } from '../common/termios.ts'; export async function main(): Promise { - const t = await getTermios() + const t = await getTermios(); t.enableRawMode(); const decoder = new TextDecoder(); @@ -18,4 +18,4 @@ export async function main(): Promise { } return -1; -} \ No newline at end of file +} diff --git a/src/scroll.ts b/src/scroll.ts index 8fd5339..3cda157 100644 --- a/src/scroll.ts +++ b/src/scroll.ts @@ -8,7 +8,7 @@ export enum RunTime { Unknown = 'common', } -import { importForRuntime } from "./common/index.ts"; +import { importForRuntime } from './common/index.ts'; /** * Determine the runtime strategy, and go!