// Remove a file. import { unlinkSync, readdirSync } from "fs" import { join } from "path" import { projectDir } from "@/project" import { sessionGet } from "@/session" export default function (path: string) { let target = "" if (path.endsWith("/")) path = path.slice(0, path.length - 1) const root = sessionGet("cwd") || projectDir() for (const file of readdirSync(root, { withFileTypes: true })) if (file.name === path) { if (file.isDirectory()) return { error: "Use `rmdir` to remove directory" } target = file.name break } if (!target) return { error: `${path} not found` } unlinkSync(join(root, path)) return `${path} removed` }