From 826295aaf5962ec3f9f9f365e7e9af8eca2873c9 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 9 Nov 2023 12:31:16 +0100 Subject: [PATCH] meta: fix build of TypeScript plugins --- bin/build-ts.mjs | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/bin/build-ts.mjs b/bin/build-ts.mjs index 1d68c95ccd..f003fd8766 100644 --- a/bin/build-ts.mjs +++ b/bin/build-ts.mjs @@ -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}`)))), +])