Files
anomalyco_opencode/packages/opencode/src/util/filesystem.ts
T
2025-06-09 15:28:06 -04:00

19 lines
505 B
TypeScript

import { exists } from "fs/promises"
import { dirname, join } from "path"
export namespace Filesystem {
export async function findUp(target: string, start: string, stop?: string) {
let current = start
const result = []
while (true) {
const search = join(current, target)
if (await exists(search)) result.push(search)
if (stop === current) break
const parent = dirname(current)
if (parent === current) break
current = parent
}
return result
}
}