| 13 | } |
| 14 | |
| 15 | export async function findUp(target: string, start: string, stop?: string) { |
| 16 | let current = start |
| 17 | const result = [] |
| 18 | while (true) { |
| 19 | const search = join(current, target) |
| 20 | if (await exists(search)) result.push(search) |
| 21 | if (stop === current) break |
| 22 | const parent = dirname(current) |
| 23 | if (parent === current) break |
| 24 | current = parent |
| 25 | } |
| 26 | return result |
| 27 | } |
| 28 | |
| 29 | export async function* up(options: { targets: string[]; start: string; stop?: string }) { |
| 30 | const { targets, start, stop } = options |