( repoRoot = WRAPPER_HARNESS_REPO_ROOT, )
| 221 | } |
| 222 | |
| 223 | export function findCompiledBinaryCandidates( |
| 224 | repoRoot = WRAPPER_HARNESS_REPO_ROOT, |
| 225 | ): string[] { |
| 226 | const explicitBinary = process.env.NCODE_TEST_COMPILED_BINARY |
| 227 | if (explicitBinary && existsSync(explicitBinary)) { |
| 228 | return [explicitBinary] |
| 229 | } |
| 230 | |
| 231 | const packageRoot = join(repoRoot, '.tmp', 'packages') |
| 232 | if (existsSync(packageRoot)) { |
| 233 | const packageMatches = readdirSync(packageRoot, { withFileTypes: true }) |
| 234 | .filter(entry => entry.isDirectory()) |
| 235 | .map(entry => join(packageRoot, entry.name, process.platform === 'win32' ? 'ncode.exe' : 'ncode')) |
| 236 | .filter(candidate => existsSync(candidate)) |
| 237 | .sort((a, b) => statSync(b).mtimeMs - statSync(a).mtimeMs) |
| 238 | if (packageMatches.length > 0) { |
| 239 | return packageMatches |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | const buckOutRoot = join(repoRoot, 'buck-out') |
| 244 | if (!existsSync(buckOutRoot)) { |
| 245 | return [] |
| 246 | } |
| 247 | |
| 248 | const candidateRoots = readdirSync(buckOutRoot, { withFileTypes: true }) |
| 249 | .filter(entry => entry.isDirectory()) |
| 250 | .flatMap(entry => [ |
| 251 | join(buckOutRoot, entry.name, 'art/fbcode'), |
| 252 | join(buckOutRoot, entry.name, 'gen/fbcode'), |
| 253 | ]) |
| 254 | .filter(candidateRoot => existsSync(candidateRoot)) |
| 255 | |
| 256 | const matches = candidateRoots |
| 257 | .flatMap(candidateRoot => |
| 258 | readdirSync(candidateRoot, { withFileTypes: true }) |
| 259 | .filter(entry => entry.isDirectory()) |
| 260 | .map(entry => |
| 261 | join(candidateRoot, entry.name, 'code/__self_contained_bin__/out/ncode'), |
| 262 | ), |
| 263 | ) |
| 264 | .filter(candidate => existsSync(candidate)) |
| 265 | .sort((a, b) => statSync(b).mtimeMs - statSync(a).mtimeMs) |
| 266 | |
| 267 | return matches |
| 268 | } |
| 269 | |
| 270 | export function resolveCompiledBinaryPath( |
| 271 | repoRoot = WRAPPER_HARNESS_REPO_ROOT, |
no test coverage detected