Find the nearest ancestor dir that contains a `.trellis/` folder.
(cwd: string)
| 44 | |
| 45 | /** Find the nearest ancestor dir that contains a `.trellis/` folder. */ |
| 46 | async function findTrellisRoot(cwd: string): Promise<string | null> { |
| 47 | let dir = path.resolve(cwd); |
| 48 | const root = path.parse(dir).root; |
| 49 | while (true) { |
| 50 | try { |
| 51 | const st = await fs.stat(path.join(dir, '.trellis')); |
| 52 | if (st.isDirectory()) return dir; |
| 53 | } catch { /* keep walking */ } |
| 54 | const parent = path.dirname(dir); |
| 55 | if (parent === dir || dir === root) break; |
| 56 | dir = parent; |
| 57 | } |
| 58 | return null; |
| 59 | } |
| 60 | |
| 61 | /** Read every markdown file directly under `dir` (one level), oldest→newest by name. */ |
| 62 | async function readMarkdownDir(dir: string): Promise<Array<{ name: string; content: string; mtimeMs: number }>> { |
no test coverage detected