Skip to content

Commit f3ff7ea

Browse files
committed
👷 change how we compute the migration progress
Issue: CLDSRV-860
1 parent 68ce4e6 commit f3ff7ea

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

.github/scripts/count-async-functions.mjs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,21 @@ for (const sourceFile of project.getSourceFiles()) {
6767
}
6868
}
6969

70-
const migrationPercent = totalFunctions > 0
70+
const asyncFunctionPercent = totalFunctions > 0
7171
? ((asyncFunctions / totalFunctions) * 100).toFixed(1)
7272
: '0.0';
7373

74+
const migrationPercent = (asyncFunctions + callbackFunctions) > 0
75+
? ((asyncFunctions / (asyncFunctions + callbackFunctions)) * 100).toFixed(1)
76+
: '0.0';
77+
7478
console.log('=== Async/Await Migration Progress ===');
7579
console.log(`Total functions: ${totalFunctions}`);
76-
console.log(`Async functions: ${asyncFunctions} (${migrationPercent}%)`);
80+
console.log(`Async functions: ${asyncFunctions} (${asyncFunctionPercent}%)`);
7781
console.log(`Callback functions: ${callbackFunctions}`);
7882
console.log(`Remaining .then(): ${thenChains}`);
7983
console.log('');
80-
console.log(`Migration: ${asyncFunctions}/${totalFunctions} functions (${migrationPercent}%)`);
84+
console.log(`Migration (trend): ${asyncFunctions}/${asyncFunctions + callbackFunctions} (${migrationPercent}%)`);
8185

8286
if (process.env.GITHUB_STEP_SUMMARY) {
8387
const { appendFileSync } = await import('node:fs');
@@ -87,9 +91,10 @@ if (process.env.GITHUB_STEP_SUMMARY) {
8791
`| Metric | Count |`,
8892
`|--------|-------|`,
8993
`| Total functions | ${totalFunctions} |`,
90-
`| Async functions | ${asyncFunctions} (${migrationPercent}%) |`,
94+
`| Async functions | ${asyncFunctions} (${asyncFunctionPercent}%) |`,
9195
`| Callback-style functions | ${callbackFunctions} |`,
9296
`| Remaining \`.then()\` chains | ${thenChains} |`,
97+
`| Migration trend (async / (async + callback)) | ${asyncFunctions}/${asyncFunctions + callbackFunctions} (${migrationPercent}%) |`,
9398
'',
9499
].join('\n'));
95100
}

0 commit comments

Comments
 (0)