(
absoluteDirectory: string,
directoryPart: string
)
| 150 | |
| 151 | const fallbackMatches: MentionCandidate[] = []; |
| 152 | const visit = async ( |
| 153 | absoluteDirectory: string, |
| 154 | directoryPart: string |
| 155 | ): Promise<void> => { |
| 156 | const entries = await readdir(absoluteDirectory, { withFileTypes: true }); |
| 157 | |
| 158 | for (const entry of entries) { |
| 159 | if (!showHiddenEntries && entry.name.startsWith(".")) { |
| 160 | continue; |
| 161 | } |
| 162 | |
| 163 | if ( |
| 164 | entry.isDirectory() |
| 165 | && RECURSIVE_MENTION_IGNORED_DIRECTORIES.has(entry.name) |
| 166 | ) { |
| 167 | continue; |
| 168 | } |
| 169 | |
| 170 | const path = directoryPart ? `${directoryPart}/${entry.name}` : entry.name; |
| 171 | const kind: MentionCandidate["kind"] = |
| 172 | entry.isDirectory() ? "directory" : "file"; |
| 173 | |
| 174 | if (entry.name.toLowerCase().startsWith(lowercasePrefix)) { |
| 175 | fallbackMatches.push({ |
| 176 | path: kind === "directory" ? `${path}/` : path, |
| 177 | kind, |
| 178 | }); |
| 179 | if (fallbackMatches.length >= MAX_FALLBACK_MENTION_CANDIDATES) { |
| 180 | return; |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | if (entry.isDirectory()) { |
| 185 | await visit(resolve(absoluteDirectory, entry.name), path); |
| 186 | if (fallbackMatches.length >= MAX_FALLBACK_MENTION_CANDIDATES) { |
| 187 | return; |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | }; |
| 192 | |
| 193 | await visit(CURRENT_DIRECTORY, ""); |
| 194 | return fallbackMatches.sort((left, right) => left.path.localeCompare(right.path)); |
no outgoing calls
no test coverage detected