/
run.ts
31 lines (25 loc) · 874 Bytes
/
run.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
import * as fs from 'fs'
import * as path from 'path'
import { spawnSync } from 'child_process'
import { invariant } from 'outvariant'
import tsPackageJson from 'typescript/package.json'
const tsInstalledVersion = tsPackageJson.version
invariant(
tsInstalledVersion,
'Failed to run typings tests: unable to determine TypeScript version',
)
const tsVersionMajorMinor = tsInstalledVersion.substring(
0,
tsInstalledVersion.lastIndexOf('.'),
)
const tsConfigPaths = [
path.resolve(__dirname, `tsconfig.${tsVersionMajorMinor}.json`),
path.resolve(__dirname, 'tsconfig.json'),
]
const tsConfigPath = tsConfigPaths.find((path) => fs.existsSync(path)) as string
console.log('Using tsconfig at "%s"', tsConfigPath)
const { status } = spawnSync('tsc', ['-p', tsConfigPath], {
cwd: path.resolve(__dirname, '../..'),
stdio: 'inherit',
})
process.exit(status || 0)