-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! chore: use new performant 'type-check' for tools tagged libaries
- Loading branch information
Showing
3 changed files
with
63 additions
and
7 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// @ts-check | ||
|
||
import fs from 'node:fs'; | ||
import { fileURLToPath } from 'node:url'; | ||
import path from 'node:path'; | ||
import { promisify } from 'node:util'; | ||
import { exec } from 'node:child_process'; | ||
import { exit } from 'node:process'; | ||
|
||
const asyncExec = promisify(exec); | ||
|
||
main().catch(err => { | ||
console.error(err); | ||
exit(1); | ||
}); | ||
|
||
/** | ||
* Copied from ${@link 'file://./../../../scripts/tasks/src/type-check.ts'} | ||
*/ | ||
async function main() { | ||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
const rootConfig = JSON.parse(fs.readFileSync(path.join(__dirname, '../tsconfig.json'), 'utf-8')); | ||
|
||
const tsConfigsRefs = getTsConfigs(rootConfig, { spec: false, e2e: false }); | ||
|
||
const asyncQueue = []; | ||
|
||
for (const ref of tsConfigsRefs) { | ||
const program = `tsc -p ${ref} --pretty --noEmit --baseUrl .`; | ||
asyncQueue.push(asyncExec(program)); | ||
} | ||
|
||
return Promise.all(asyncQueue).catch(err => { | ||
console.error(err.stdout); | ||
exit(1); | ||
}); | ||
} | ||
|
||
/** | ||
* @param {{references?: Array<{ path: string }>;}} solutionConfig | ||
* @param {{ spec: boolean, e2e: boolean }} exclude | ||
*/ | ||
function getTsConfigs(solutionConfig, exclude) { | ||
const refs = solutionConfig.references ?? []; | ||
/** @type {string[]} */ | ||
const refsPaths = []; | ||
|
||
for (const ref of refs) { | ||
if (exclude.spec && ref.path.includes('spec')) { | ||
continue; | ||
} | ||
if (exclude.e2e && ref.path.includes('cy')) { | ||
continue; | ||
} | ||
|
||
refsPaths.push(ref.path); | ||
} | ||
|
||
return refsPaths; | ||
} |