-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
keep PropTypes in sync with TS changes
- Loading branch information
1 parent
b3a314d
commit 2ee3818
Showing
4 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
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,65 @@ | ||
const childProcess = require('child_process'); | ||
const path = require('path'); | ||
const { chunk } = require('lodash'); | ||
const glob = require('fast-glob'); | ||
const { promisify } = require('util'); | ||
|
||
const exec = promisify(childProcess.exec); | ||
const packageRoot = path.resolve(__dirname, '../'); | ||
|
||
async function test(tsconfigPath) { | ||
try { | ||
await exec(['yarn', 'tsc', '--project', tsconfigPath].join(' '), { cwd: packageRoot }); | ||
} catch (error) { | ||
if (error.stdout !== undefined) { | ||
// `exec` error | ||
throw new Error(`exit code ${error.code}: ${error.stdout}`); | ||
} | ||
// Unknown error | ||
throw error; | ||
} | ||
} | ||
|
||
/** | ||
* Tests various module augmentation scenarios. | ||
* We can't run them with a single `tsc` run since these apply globally. | ||
* Running them all would mean they're not isolated. | ||
* Each test case represents a section in our docs. | ||
* | ||
* We're not using mocha since mocha is used for runtime tests. | ||
* This script also allows us to test in parallel which we can't do with our mocha tests. | ||
*/ | ||
async function main() { | ||
const tsconfigPaths = await glob('test/typescript/moduleAugmentation/*.tsconfig.json', { | ||
absolute: true, | ||
cwd: packageRoot, | ||
}); | ||
// Need to process in chunks or we might run out-of-memory | ||
// approximate yarn lerna --concurrency 7 | ||
const tsconfigPathsChunks = chunk(tsconfigPaths, 7); | ||
|
||
// eslint-disable-next-line no-restricted-syntax | ||
for await (const tsconfigPathsChunk of tsconfigPathsChunks) { | ||
await Promise.all( | ||
tsconfigPathsChunk.map(async (tsconfigPath) => { | ||
await test(tsconfigPath).then( | ||
() => { | ||
// eslint-disable-next-line no-console -- test runner feedback | ||
console.log(`PASS ${path.relative(process.cwd(), tsconfigPath)}`); | ||
}, | ||
(error) => { | ||
// don't bail but log the error | ||
console.error(`FAIL ${path.relative(process.cwd(), tsconfigPath)}\n ${error}`); | ||
// and mark the test as failed | ||
process.exitCode = 1; | ||
}, | ||
); | ||
}), | ||
); | ||
} | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
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
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