some stuff

This commit is contained in:
Chris Wanstrath 2025-10-01 21:39:43 -07:00
parent e88627693c
commit dda1cc1f21
10 changed files with 6 additions and 24 deletions

View File

@ -5,7 +5,6 @@ import { readdirSync } from "fs"
import { join, extname } from "path"
import type { CommandOutput } from "@/shared/types"
import { NOSE_WWW } from "@/config"
import { isBinaryFile } from "@/utils"
import { projectName, projectDir } from "@/project"
import { sessionGet } from "@/session"
@ -21,10 +20,6 @@ export default async function (path: string) {
files.push(file.name)
}
if (root === NOSE_WWW) {
files = files.filter(file => file.endsWith(`${project}.ts`) || file.endsWith(`${project}.tsx`))
}
if (!files.includes(path))
return { error: `file not found: ${path}` }

View File

@ -4,7 +4,6 @@ import { readdirSync } from "fs"
import { join, extname } from "path"
import type { CommandOutput } from "@/shared/types"
import { NOSE_WWW } from "@/config"
import { isBinaryFile } from "@/utils"
import { countChar } from "@/shared/utils"
import { projectName, projectDir } from "@/project"
@ -20,10 +19,6 @@ export default async function (path: string) {
files.push(file.name)
}
if (root === NOSE_WWW) {
files = files.filter(file => file.endsWith(`${project}.ts`) || file.endsWith(`${project}.tsx`))
}
if (files.includes(path))
return await readFile(join(root, path))
else

View File

@ -1,12 +1,10 @@
// Look around.
import { readdirSync } from "fs"
import { NOSE_WWW } from "@/config"
import { projectName, projectDir } from "@/project"
import { sessionGet } from "@/session"
export default function () {
const project = projectName()
const root = sessionGet("cwd") || projectDir()
let files: string[] = []
@ -15,10 +13,6 @@ export default function () {
files.push(file.isDirectory() ? `${file.name}/` : file.name)
}
if (root === NOSE_WWW) {
files = files.filter(file => file.endsWith(`${project}.ts`) || file.endsWith(`${project}.tsx`))
}
return <>
{root !== projectDir() && <a href="#cd ..;ls">..</a>}
{files.map(file =>

View File

@ -1,6 +1,5 @@
export default async function reboot() {
setTimeout(async () => await Bun.$`reboot`, 1000)
console.log("REBOOTING...")
return {
text: "Rebooting... This will take about 10 seconds.",

View File

@ -1,6 +1,5 @@
export default function restart() {
setTimeout(() => process.exit(), 1000)
console.log("RESTARTING...")
return {
text: "Restarting... This will take a second or two.",

View File

@ -65,9 +65,6 @@ export function draw(game: GameContext) {
const offsetX = (game.width - boardW) / 2
const offsetY = (game.height - boardH) / 2
console.log("X", offsetX)
console.log("Y", offsetY)
const c = game.ctx
c.save()
c.translate(offsetX, offsetY)

View File

@ -58,7 +58,6 @@ export function routes(def: Record<string, Handler>): Hono {
const method = parts[0] || "GET"
const path = parts[1] || "/"
console.log(method, path, def[key])
//@ts-ignore
app.on(method, path, async c => toResponse(await def[key](c)))
}

View File

@ -15,7 +15,7 @@ let ws: WebSocket | null = null
// open our websocket connection
export function startConnection() {
const url = new URL('/ws', location.href)
const url = new URL(`/ws?session=${sessionId}`, location.href)
url.protocol = url.protocol.replace('http', 'ws')
ws = new WebSocket(url)

View File

@ -34,3 +34,8 @@ export function randomIndex<T>(list: T[]): number | undefined {
if (!list.length) return
return rng(0, list.length - 1)
}
// unique([1,1,2,2,3,3]) #=> [1,2,3]
export function unique<T>(array: T[]): T[] {
return [...new Set(array)]
}

View File

@ -31,7 +31,6 @@ export function expectDir(path: string): boolean {
export async function expectShellCmd(cmd: string): Promise<boolean> {
try {
await $`which ${cmd}`
console.log("WHICH", cmd)
return true
} catch {
setFatal(`Missing critical dependency: avahi-publish`)