| 1 | /* eslint-disable no-console */ |
| 2 | import { packageOptions } from './common.js'; |
| 3 | import { execSync } from 'child_process'; |
| 4 | |
| 5 | const buildType = (packageName: string) => { |
| 6 | console.log(`Building types for ${packageName}`); |
| 7 | try { |
| 8 | const out = execSync(`tsc -p ./packages/${packageName}/tsconfig.json --emitDeclarationOnly`); |
| 9 | if (out.length > 0) { |
| 10 | console.log(out.toString()); |
| 11 | } |
| 12 | } catch (e) { |
| 13 | if (e.stdout.length > 0) { |
| 14 | console.error(e.stdout.toString()); |
| 15 | } |
| 16 | if (e.stderr.length > 0) { |
| 17 | console.error(e.stderr.toString()); |
| 18 | } |
| 19 | // Exit the build process if we are in CI |
| 20 | if (process.env.CI) { |
| 21 | throw new Error(`Failed to build types for ${packageName}`); |
| 22 | } |
| 23 | } |
| 24 | }; |
| 25 | |
| 26 | for (const { packageName } of Object.values(packageOptions)) { |
| 27 | buildType(packageName); |
| 28 | } |
| 29 | |