17 lines
517 B
TypeScript
17 lines
517 B
TypeScript
// Create an empty text file.
|
|
|
|
import { join } from "path"
|
|
import { readdirSync } from "fs"
|
|
import { projectDir } from "@/project"
|
|
import { sessionGet } from "@/session"
|
|
|
|
export default async function (path: string) {
|
|
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) throw `${path} exists`
|
|
|
|
await Bun.write(join(root, path), "")
|
|
return `${path} created`
|
|
} |