From 0202ebb21764e41d9b22bd9a6c2798cda5940a2c Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Sun, 28 Sep 2025 14:19:08 -0700 Subject: [PATCH] appDir --- app/nose/bin/cat.ts | 4 ++-- app/nose/bin/edit.tsx | 4 ++-- app/nose/bin/ls.ts | 4 ++-- app/src/webapp.ts | 9 ++++----- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/nose/bin/cat.ts b/app/nose/bin/cat.ts index 6c7b3d2..4ee70af 100644 --- a/app/nose/bin/cat.ts +++ b/app/nose/bin/cat.ts @@ -5,7 +5,7 @@ import { join, extname } from "path" import type { CommandOutput } from "app/src/shared/types" import { NOSE_WWW } from "app/src/config" import { getState } from "@/session" -import { appPath } from "app/src/webapp" +import { appDir } from "app/src/webapp" import { isBinaryFile } from "app/src/utils" import { highlight } from "../lib/highlight" @@ -16,7 +16,7 @@ export default async function (path: string) { const project = state.project if (!project) return { error: "no project loaded" } - const root = appPath(project) + const root = appDir(project) if (!root) return { error: "error loading project" } let files: string[] = [] diff --git a/app/nose/bin/edit.tsx b/app/nose/bin/edit.tsx index c0707f5..ab94707 100644 --- a/app/nose/bin/edit.tsx +++ b/app/nose/bin/edit.tsx @@ -5,7 +5,7 @@ import { join, extname } from "path" import type { CommandOutput } from "app/src/shared/types" import { NOSE_WWW } from "app/src/config" import { getState } from "@/session" -import { appPath } from "app/src/webapp" +import { appDir } from "app/src/webapp" import { isBinaryFile } from "app/src/utils" import { countChar } from "app/src/shared/utils" @@ -16,7 +16,7 @@ export default async function (path: string) { const project = state.project if (!project) return { error: "no project loaded" } - const root = appPath(project) + const root = appDir(project) if (!root) return { error: "error loading project" } let files: string[] = [] diff --git a/app/nose/bin/ls.ts b/app/nose/bin/ls.ts index 58ac326..cccced5 100644 --- a/app/nose/bin/ls.ts +++ b/app/nose/bin/ls.ts @@ -1,7 +1,7 @@ import { readdirSync } from "fs" import { NOSE_WWW } from "app/src/config" import { getState } from "@/session" -import { appPath } from "app/src/webapp" +import { appDir } from "app/src/webapp" export default function () { const state = getState() @@ -10,7 +10,7 @@ export default function () { const project = state.project if (!project) return { error: "no project loaded" } - const root = appPath(project) + const root = appDir(project) if (!root) return { error: "error loading project" } let files: string[] = [] diff --git a/app/src/webapp.ts b/app/src/webapp.ts index 2a9aa49..e3b8737 100644 --- a/app/src/webapp.ts +++ b/app/src/webapp.ts @@ -33,20 +33,19 @@ export function apps(): string[] { return apps.sort() } -export function appPath(name: string): string | undefined { +export function appDir(name: string): string | undefined { const path = [ `${name}.ts`, `${name}.tsx`, - join(name, "index.ts"), - join(name, "index.tsx") + name ] .map(path => join(NOSE_WWW, path)) .flat() - .filter(path => isFile(path))[0] + .filter(path => /\.tsx?$/.test(path) ? isFile(path) : isDir(path))[0] if (!path) return - return dirname(path) + return /\.tsx?$/.test(path) ? dirname(path) : path } async function findApp(name: string): Promise {