| 1328 | const scriptsDir = path.resolve(__dirname, '..', 'src', 'adapters', 'scripts'); |
| 1329 | |
| 1330 | function collectRelativeRequires() { |
| 1331 | const entries = fs.readdirSync(scriptsDir).filter(f => f.endsWith('.js')); |
| 1332 | const requires = new Set(); |
| 1333 | for (const entry of entries) { |
| 1334 | const src = fs.readFileSync(path.join(scriptsDir, entry), 'utf8'); |
| 1335 | // Match `require('./foo')` and `require("./foo")` for any "./..." |
| 1336 | // path that targets a sibling file (not a node_modules package). |
| 1337 | const re = /require\(\s*['"](\.\/[^'"]+)['"]\s*\)/g; |
| 1338 | let m; |
| 1339 | while ((m = re.exec(src)) !== null) { |
| 1340 | // Normalise: ensure .js suffix for matching against directory list. |
| 1341 | let target = m[1].replace(/^\.\//, ''); |
| 1342 | if (target.includes('/')) continue; // only verify same-dir sibling helpers |
| 1343 | if (!target.endsWith('.js')) target += '.js'; |
| 1344 | requires.add(target); |
| 1345 | } |
| 1346 | } |
| 1347 | return [...requires]; |
| 1348 | } |
| 1349 | |
| 1350 | it('every local require in adapter scripts points to a file that actually exists in scripts/', () => { |
| 1351 | const requires = collectRelativeRequires(); |