This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { readdir, readFile, stat, writeFile } from 'node:fs/promises'
|
||||
import { readdir, readFile, rm, stat, writeFile } from 'node:fs/promises'
|
||||
import { join, relative, sep } from 'node:path'
|
||||
import { listFiles } from './search-service'
|
||||
|
||||
@@ -120,6 +120,13 @@ export async function writeProjectFile(root: string, rel: string, content: strin
|
||||
await writeFile(join(root, rel), content, 'utf8')
|
||||
}
|
||||
|
||||
/** Delete a project file or folder (relative path). Stays inside the project root. */
|
||||
export async function deleteProjectFile(root: string, rel: string): Promise<void> {
|
||||
const target = join(root, rel)
|
||||
if (relative(root, target).startsWith('..')) return // guard against escaping the root
|
||||
await rm(target, { recursive: true, force: true })
|
||||
}
|
||||
|
||||
/**
|
||||
* In-memory content index of all (small, text) files — powers content viewing.
|
||||
* Primary: read the rg file list; fallback: walk. Capped for large repos.
|
||||
|
||||
Reference in New Issue
Block a user