| 1 | #!/usr/bin/env node |
| 2 | |
| 3 | import fs from 'node:fs'; |
| 4 | import path from 'node:path'; |
| 5 | import { pathToFileURL, fileURLToPath } from 'node:url'; |
| 6 | |
| 7 | const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
| 8 | const candidates = [ |
| 9 | path.join(__dirname, 'detector', 'detect-antipatterns.mjs'), |
| 10 | path.join(__dirname, '..', '..', 'cli', 'engine', 'detect-antipatterns.mjs'), |
| 11 | ]; |
| 12 | const detectorPath = candidates.find(p => fs.existsSync(p)); |
| 13 | |
| 14 | if (!detectorPath) { |
| 15 | process.stderr.write('Error: bundled detector not found.\n'); |
| 16 | process.exit(1); |
| 17 | } |
| 18 | |
| 19 | const { detectCli } = await import(pathToFileURL(detectorPath)); |
| 20 | |
| 21 | await detectCli(); |
| 22 |