Skip to content

Commit

Permalink
meta: fix build of TypeScript plugins (#4784)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 authored Nov 9, 2023
1 parent b6f34b2 commit 70ffe60
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions bin/build-ts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,25 @@ const argv0 = fromYarn ? [] : ['yarn']

const cwd = fileURLToPath(new URL('../', import.meta.url))

const locations = []

for await (const line of readLines(stdin)) {
const { location, name } = JSON.parse(line)
const { location } = JSON.parse(line)
if (existsSync(path.join(cwd, location, 'tsconfig.json'))) {
const cp = spawn(exe, [...argv0, 'tsc', '-p', location], {
stdio: 'inherit',
cwd,
})
await Promise.race([
once(cp, 'error').then(err => Promise.reject(err)),
await once(cp, 'exit')
.then(([code]) => (code && Promise.reject(new Error(`Non-zero exit code when building "${name}": ${code}`)))),
])
locations.unshift(location)
}
if (existsSync(path.join(cwd, location, 'tsconfig.build.json'))) {
const cp = spawn(exe, [...argv0, 'tsc', '--build', path.join(cwd, location, 'tsconfig.build.json')], {
stdio: 'inherit',
cwd,
})
await Promise.race([
once(cp, 'error').then(err => Promise.reject(err)),
await once(cp, 'exit')
.then(([code]) => (code && Promise.reject(new Error(`Non-zero exit code when building "${name}": ${code}`)))),
])
const tsConfigBuildPath = path.join(cwd, location, 'tsconfig.build.json')
if (existsSync(tsConfigBuildPath)) {
locations.push(tsConfigBuildPath)
}
}

const cp = spawn(exe, [...argv0, 'tsc', '--build', ...locations], {
stdio: 'inherit',
cwd,
})
await Promise.race([
once(cp, 'error').then(err => Promise.reject(err)),
await once(cp, 'exit')
.then(([code]) => (code && Promise.reject(new Error(`Non-zero exit code when building TS projects: ${code}`)))),
])

0 comments on commit 70ffe60

Please sign in to comment.