forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildTs.js
48 lines (40 loc) · 1.16 KB
/
buildTs.js
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
39
40
41
42
43
44
45
46
47
48
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
const fs = require('fs');
const path = require('path');
const chalk = require('chalk');
const execa = require('execa');
const {getPackages, adjustToTerminalWidth, OK} = require('./buildUtils');
const packages = getPackages();
const packagesWithTs = packages.filter(p =>
fs.existsSync(path.resolve(p, 'tsconfig.json'))
);
const args = [
'--max-old-space-size=4096',
path.resolve(
require.resolve('typescript/package.json'),
'..',
require('typescript/package.json').bin.tsc
),
'-b',
...packagesWithTs,
...process.argv.slice(2),
];
console.log(chalk.inverse('Building TypeScript definition files'));
process.stdout.write(adjustToTerminalWidth('Building\n'));
try {
execa.sync('node', args, {stdio: 'inherit'});
process.stdout.write(`${OK}\n`);
} catch (e) {
process.stdout.write('\n');
console.error(
chalk.inverse.red('Unable to build TypeScript definition files')
);
console.error(e.stack);
process.exitCode = 1;
}