(input: { directories: string[]; cwd: string })
| 113 | } |
| 114 | |
| 115 | async function opencodeFiles(input: { directories: string[]; cwd: string }) { |
| 116 | const files = [ |
| 117 | ...ConfigPaths.fileInDirectory(Global.Path.config, "opencode"), |
| 118 | ...(await Filesystem.findUp(["opencode.json", "opencode.jsonc"], input.cwd, undefined, { rootFirst: true })), |
| 119 | ] |
| 120 | for (const dir of unique(input.directories)) { |
| 121 | files.push(...ConfigPaths.fileInDirectory(dir, "opencode")) |
| 122 | } |
| 123 | if (Flag.OPENCODE_CONFIG) files.push(Flag.OPENCODE_CONFIG) |
| 124 | |
| 125 | const existing = await Promise.all( |
| 126 | unique(files).map(async (file) => { |
| 127 | const ok = await Filesystem.exists(file) |
| 128 | return ok ? file : undefined |
| 129 | }), |
| 130 | ) |
| 131 | return existing.filter((file): file is string => !!file) |
| 132 | } |
no test coverage detected