// Open the Advanced Text Editor and start editing a file. 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" import { sessionGet } from "@/session" export default async function (path: string) { const project = projectName() const root = sessionGet("cwd") || projectDir() let files: string[] = [] for (const file of readdirSync(root, { withFileTypes: true })) { 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 return await newFile(join(root, path)) } async function readFile(path: string): Promise { const ext = extname(path).slice(1) const file = Bun.file(path) if (await isBinaryFile(path)) throw "Cannot display binary file" const text = await file.text() const rows = countChar(text, "\n") + 1 return } async function newFile(path: string): Promise { return }