Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the minify CLI tools to properly catch execution errors and set a non-zero exit code, and adds a test to verify this behavior. A review comment suggests improving the test's path resolution for the CLI script to ensure it works reliably in both compiled and source environments.
| const cliPath = path.join( | ||
| __dirname, | ||
| '..', | ||
| '..', | ||
| 'bin', | ||
| 'minifyProtoJson.js', | ||
| ); |
There was a problem hiding this comment.
The relative path resolution using ../../bin/minifyProtoJson.js assumes the test is always executed from the compiled build/test directory. If the tests are run directly from the source directory (e.g., using ts-node or tsx during development), __dirname will be core/packages/tools/test, and going up two levels will resolve to core/packages/bin/minifyProtoJson.js which does not exist.
To make this robust across both compiled and source environments, consider dynamically resolving the path based on whether __dirname contains build (or dist), or use process.cwd() if the tests are guaranteed to run from the package root.
const cliPath = path.resolve(
__dirname,
__dirname.includes('build')
? '../../bin/minifyProtoJson.js'
: '../bin/minifyProtoJson.js'
);
Description
Handles rejected promises in
minifyProtoJsonso CLI failures exit non-zero.Impact
Prevents build scripts from silently ignoring proto minification errors.
Changes
main(process.argv[2])incore/packages/tools/src/minify.tsandcore/packages/tools/bin/minifyProtoJson.js, logging errors and settingprocess.exitCode = 1.@typescript-eslint/no-floating-promiseslint suppression insrc/minify.ts.bin/minifyProtoJson.jsexits with status1when minification fails.Testing
core/packages/tools(pnpm --dir core/packages/tools testandpnpm --dir core/packages/tools run lint).Alternatives
main(process.argv[2])unawaited risks silent exit code discrepancies when a target directory or proto JSON file is missing or malformed.