-
Notifications
You must be signed in to change notification settings - Fork 86
/
build.ts
executable file
·38 lines (29 loc) · 1.18 KB
/
build.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env ts-node-script
import execa from 'execa';
import isCI from 'is-ci';
import { runAsyncProcess } from '../utils/run-async-process';
import { handleError } from '../utils/handle-script-error';
import { printSeparator } from '../utils/print-separator';
import { getPackages, logPackages, promptForPackage } from '../utils/workspace-helpers';
import { environment, logEnvironment } from '../utils/environment';
async function buildPkgs(PKG: string) {
printSeparator('Building');
// We need to limit concurrency in CI to avoid ENOMEM errors.
const wsrunConcurrency = isCI ? '--serial' : '--stages';
await execa('yarn', ['wsrun', '-r', wsrunConcurrency, `${process.env.INIT_CWD}/scripts/bin/wsrun/build-package.ts`], {
stdio: 'inherit',
env: { PKG },
})
.then(() => console.log())
.catch(handleError('Failed to build libraries.'));
}
async function main() {
const PKG = await promptForPackage();
const { packages } = await getPackages(PKG);
console.log(`\nFound ${packages.length} packages to build:`);
logPackages(packages);
console.log(`\nBuilding with the following environment:`);
logEnvironment();
await buildPkgs(PKG);
}
runAsyncProcess(main);