Skip to content

fix(cli): normalize language/extension casing for CLI inputs#1245

Merged
antfu merged 5 commits into
shikijs:mainfrom
Nandann018-ux:main
Feb 25, 2026
Merged

fix(cli): normalize language/extension casing for CLI inputs#1245
antfu merged 5 commits into
shikijs:mainfrom
Nandann018-ux:main

Conversation

@Nandann018-ux

Copy link
Copy Markdown
Contributor

Fix case sensitivity in CLI language inference and --lang handling

Summary

This PR fixes a case-sensitivity edge case in the CLI’s language inference and explicit language selection.

Previously, language detection relied directly on the file extension or the --lang flag as provided. Since Shiki language identifiers are lowercase, inputs such as:

  • FILE.TS
  • README.MD
  • --lang PYTHON

could fail to resolve correctly. This issue was especially noticeable on Windows or when working on files shared across systems where uppercase extensions are common.

Changes

  • Normalize URL extension parsing to lowercase.
  • Normalize local file extension parsing to lowercase.
  • Normalize the effective CLI lang value (whether inferred or passed via --lang) to lowercase.
  • Add test coverage for:
    • Uppercase file extension parsing
    • Uppercase --lang usage

Why This Matters

  • Improves CLI robustness with real-world file naming conventions.
  • Prevents silent failures or unexpected “unknown language” behavior.
  • Ensures consistent behavior across platforms.

Tests

  • Added coverage in cli.test.ts
  • Verified using:
cli.test.ts --run

Add proper type declarations for subpath exports in engine packages:
- @shikijs/engine-oniguruma: Add types for ./wasm-inlined export
- @shikijs/engine-javascript: Add types for ./raw export

This fixes TypeScript errors when importing these subpaths.
The exports field now properly includes both 'types' and 'default' fields
for each subpath, following Node.js package exports best practices.
@netlify

netlify Bot commented Feb 22, 2026

Copy link
Copy Markdown

Deploy Preview for shiki-matsu ready!

Name Link
🔨 Latest commit 2818668
🔍 Latest deploy log https://app.netlify.com/projects/shiki-matsu/deploys/699e46eec751bf0008e27d99
😎 Deploy Preview https://deploy-preview-1245--shiki-matsu.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Feb 22, 2026

Copy link
Copy Markdown

Deploy Preview for shiki-next ready!

Name Link
🔨 Latest commit 2818668
🔍 Latest deploy log https://app.netlify.com/projects/shiki-next/deploys/699e46eec751bf0008e27d9b
😎 Deploy Preview https://deploy-preview-1245--shiki-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Feb 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.25%. Comparing base (28dd090) to head (2818668).
⚠️ Report is 19 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1245      +/-   ##
==========================================
+ Coverage   95.20%   95.25%   +0.05%     
==========================================
  Files          92       92              
  Lines        7922     8008      +86     
  Branches     1689     1704      +15     
==========================================
+ Hits         7542     7628      +86     
  Misses        374      374              
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Nandann018-ux

Copy link
Copy Markdown
Contributor Author

Please let me know if you’d like any additional changes — I’m happy to update the PR.

Comment thread packages/engine-javascript/package.json Outdated
"exports": {
".": "./dist/index.mjs",
"./raw": "./dist/engine-raw.mjs"
".": {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change is necessary, even if they do, I think it deserves to be in a separate PR.

@antfu
antfu merged commit 4bea1a5 into shikijs:main Feb 25, 2026
6 of 7 checks passed
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.

2 participants