Skip to content

Commit 5beffc8

Browse files
authored
chore: update codecov script (#3474)
1 parent 39193ca commit 5beffc8

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

scripts/codecov-upload-flags.mjs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { execSync } from 'child_process';
17+
import { execSync, execFileSync } from 'child_process';
1818
import { globSync } from 'glob';
1919
import { chmodSync, existsSync, readFileSync } from 'fs';
2020
import path from 'path';
@@ -44,17 +44,17 @@ const pkgsWithFlag = pkgFiles.flat().map(f => {
4444
// or check https://docs.codecov.com/docs/cli-options
4545
// prettier-ignore
4646
const command = [
47-
'./codecov --verbose',
48-
'upload-coverage',
49-
'--git-service github',
47+
'./codecov', '--verbose',
48+
'upload-coverage',
49+
'--git-service', 'github',
5050
// we don't need xcrun or pycoverage plugins
51-
'--plugin gcov',
52-
'--gcov-executable gcov',
53-
'--file', report,
54-
'--flag', flag,
55-
// limit any scan to the pacakge folder
56-
'--dir', path,
57-
];
51+
'--plugin', 'gcov',
52+
'--gcov-executable', 'gcov',
53+
'--file', report,
54+
'--flag', flag,
55+
// limit any scan to the package folder
56+
'--dir', path,
57+
];
5858

5959
if (typeof commitSha === 'string') {
6060
command.push('--sha', commitSha);
@@ -63,7 +63,7 @@ const pkgsWithFlag = pkgFiles.flat().map(f => {
6363
command.push('--branch', branchName);
6464
}
6565

66-
return { name, flag, path, report, command: command.join(' ') };
66+
return { name, flag, path, report, command };
6767
});
6868

6969
// Download codecov-cli if necessary
@@ -108,13 +108,14 @@ for (const pkg of pkgsWithFlag) {
108108
console.log(
109109
`\n\nCODECOV: Merging coverage reports of "${pkg.name}" into ${pkg.path}coverage/coverage-final.json.`
110110
);
111-
execSync(
112-
`cd ${pkg.path} && npx nyc merge .nyc_output coverage/coverage-final.json`,
113-
execOpts
111+
execFileSync(
112+
'npx',
113+
['nyc', 'merge', '.nyc_output', 'coverage/coverage-final.json'],
114+
{ ...execOpts, cwd: pkg.path }
114115
);
115116
console.log(
116-
`\n\nCODECOV: Uploading report of "${pkg.name}" with flag "${pkg.flag}"\n${pkg.command}`
117+
`\n\nCODECOV: Uploading report of "${pkg.name}" with flag "${pkg.flag}"\n${pkg.command.join(' ')}`
117118
);
118-
execSync(pkg.command, execOpts);
119+
execFileSync(pkg.command[0], pkg.command.slice(1), execOpts);
119120
}
120121
}

0 commit comments

Comments
 (0)