2023-04-25 11:01:25 +00:00
|
|
|
import { execFileSync } from 'child_process'
|
|
|
|
import path, { join } from 'path'
|
|
|
|
import { REPO_ROOT, readJsonIfExists } from './lib/file'
|
2023-06-01 18:01:49 +00:00
|
|
|
import { nicelog } from './lib/nicelog'
|
2023-04-25 11:01:25 +00:00
|
|
|
import { getAllWorkspacePackages } from './lib/workspace'
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
const allWorkspaces = await getAllWorkspacePackages()
|
|
|
|
const tsconfigFiles = []
|
|
|
|
for (const workspace of allWorkspaces) {
|
|
|
|
const tsconfigFile = path.join(workspace.path, 'tsconfig.json')
|
|
|
|
const tsconfigExists = await readJsonIfExists(tsconfigFile)
|
|
|
|
if (tsconfigExists) tsconfigFiles.push(tsconfigFile)
|
|
|
|
}
|
|
|
|
|
2023-06-01 18:01:49 +00:00
|
|
|
nicelog('Typechecking files:', tsconfigFiles)
|
2023-04-25 11:01:25 +00:00
|
|
|
|
|
|
|
const args = ['--build']
|
|
|
|
if (process.argv.includes('--force')) args.push('--force')
|
|
|
|
if (process.argv.includes('--watch')) args.push('--watch')
|
|
|
|
if (process.argv.includes('--preserveWatchOutput')) args.push('--preserveWatchOutput')
|
|
|
|
execFileSync(join(REPO_ROOT, 'node_modules/.bin/tsc'), [...args, ...tsconfigFiles], {
|
|
|
|
stdio: 'inherit',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
main()
|