check:mjs-parses parses with node even when the gates run under bun
Under bun, process.execPath is bun, and bun --check runs the script instead of parsing it; a cloud build hung inside check-link-rot-sample.mjs. The gate now uses node under bun and fails plainly if node is missing.
This commit is contained in:
parent
b8f77630c6
commit
ec47023575
1 changed files with 12 additions and 1 deletions
|
|
@ -57,13 +57,24 @@ if (!files.length) {
|
|||
process.exit(1)
|
||||
}
|
||||
|
||||
// Under bun, process.execPath is bun, and `bun --check` RUNS the script instead of parsing it (a cloud
|
||||
// build hung 18+ min inside check-link-rot-sample.mjs). Parse with a real node, or refuse to guess.
|
||||
let NODE = process.execPath
|
||||
if (process.versions.bun) {
|
||||
NODE = 'node'
|
||||
try { execFileSync(NODE, ['--version'], { stdio: 'pipe' }) } catch {
|
||||
console.error('MJS-PARSE: FAIL — running under bun and no `node` on PATH; this gate needs node --check (bun --check executes).')
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
const broken = []
|
||||
for (const f of files) {
|
||||
const p = join(DIR, f)
|
||||
try {
|
||||
// `node --check` is the same parser the build uses, so a pass here means the build will at
|
||||
// least get past parsing. It does not execute the module.
|
||||
execFileSync(process.execPath, ['--check', p], { stdio: 'pipe' })
|
||||
execFileSync(NODE, ['--check', p], { stdio: 'pipe' })
|
||||
} catch (e) {
|
||||
const out = String(e.stderr || e.stdout || e.message)
|
||||
// node --check prints: <path>\n<offending source line>\n<caret>\n\nSyntaxError: <msg>
|
||||
|
|
|
|||
Loading…
Reference in a new issue