Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meta: fix build of TypeScript plugins #4784

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}`)))),
])