diff --git a/test-packages/support/suite-setup-util.ts b/test-packages/support/suite-setup-util.ts index 3ae6e0886..c81fb6691 100644 --- a/test-packages/support/suite-setup-util.ts +++ b/test-packages/support/suite-setup-util.ts @@ -152,33 +152,29 @@ export async function emitDynamicSuites() { } } -if (require.main === module) { - if (process.argv.includes('--list')) { - allSuites() - .then(result => { - process.stdout.write(JSON.stringify(result, null, 2) + '\n'); - }) - .catch(err => { - process.stderr.write(err); - process.exit(-1); - }); - } +async function main() { + try { + if (process.argv.includes('--list')) { + const result = await allSuites(); - if (process.argv.includes('--matrix')) { - githubMatrix() - .then(result => { - process.stdout.write(JSON.stringify(result)); - }) - .catch(err => { - process.stderr.write(err); - process.exit(-1); - }); - } + process.stdout.write(JSON.stringify(result, null, 2) + '\n'); + } - if (process.argv.includes('--emit')) { - emitDynamicSuites().catch(err => { - console.log(err); - process.exit(-1); - }); + if (process.argv.includes('--matrix')) { + const result = await githubMatrix(); + + process.stdout.write(JSON.stringify(result)); + } + + if (process.argv.includes('--emit')) { + await emitDynamicSuites(); + } + } catch (error) { + console.error(error); + process.exitCode = -1; } } + +if (require.main === module) { + main(); +}