Commit ccbaa8b
committed
fix: resolve CLI packaging issue causing GitHub Actions failures
The tests in test/pack.test.ts were failing because the packaged CLI was
not working when installed via npm. Specifically, npx commit-msg
--version was returning exit code 1 instead of 0, causing assertions to
fail.
Root cause: The CLI entry point files were using experimental import
syntax for package.json that doesn't work reliably in packaged
environments:
import packageJson from '../../package.json' with { type: 'json' };
This syntax was causing the CLI to crash on startup in CI environments.
Solution: Replace the experimental import with Node.js's createRequire
function:
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const packageJson = require('../../package.json');
This standard approach works consistently in both development and
packaged environments, resolving the GitHub Actions test failures.
Change-Id: I95d8f9bb058dcde3f91314b9cbdbbcb9b6630a33
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>1 parent e6c5b86 commit ccbaa8b
2 files changed
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
0 commit comments