(relPath, content)
| 125 | } |
| 126 | |
| 127 | function fallbackNodeSyntaxCheck(relPath, content) { |
| 128 | const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'esim-precommit-')); |
| 129 | const ext = path.extname(relPath).toLowerCase() || '.js'; |
| 130 | const tempFile = path.join(tempDir, `check${ext}`); |
| 131 | |
| 132 | try { |
| 133 | fs.writeFileSync(tempFile, content, 'utf8'); |
| 134 | const result = spawnSync(process.execPath, ['--check', tempFile], { |
| 135 | encoding: 'utf8' |
| 136 | }); |
| 137 | if (result.status !== 0) { |
| 138 | throw new Error((result.stderr || result.stdout || '').trim()); |
| 139 | } |
| 140 | } finally { |
| 141 | fs.rmSync(tempDir, { recursive: true, force: true }); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | function checkJavaScriptSyntax(relPath, content) { |
| 146 | if (esbuild) { |
no outgoing calls
no test coverage detected