Skip to content

fix: load CLI version in ESM#47

Open
iccccccccccccc wants to merge 1 commit into
HailBytes:mainfrom
iccccccccccccc:fix-esm-cli-version
Open

fix: load CLI version in ESM#47
iccccccccccccc wants to merge 1 commit into
HailBytes:mainfrom
iccccccccccccc:fix-esm-cli-version

Conversation

@iccccccccccccc
Copy link
Copy Markdown

Fixes #24

Changes

  • create a require function with createRequire(import.meta.url) for the ESM CLI
  • read package.json through that ESM-compatible require instead of relying on a missing global require
  • keep the existing 0.0.0 fallback if the package metadata cannot be read

Verification

  • npm run build
  • node dist/cli.js --version -> 1.0.1
  • node dist/cli.js --help shows @hailbytes/security-headers v1.0.1
  • npm run typecheck

I also ran npm test; it currently gets through 55/59 tests, with four existing Permissions-Policy / grade-boundary assertions failing outside this CLI version path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REVIEW] CLI: getVersion() uses require() in ESM module — --version and --help always display 0.0.0

1 participant