Skip to content

fix(cli): fall back to 'text' when file/URL has no extension and no -… - #1248

Merged
antfu merged 1 commit into
shikijs:mainfrom
VeerShah41:fix/cli-extensionless-file-lang-fallback
Sep 11, 2026
Merged

antfu merged 1 commit into
shikijs:mainfrom
VeerShah41:fix/cli-extensionless-file-lang-fallback

Conversation

@VeerShah41

@VeerShah41 VeerShah41 commented Feb 25, 2026 •

Copy link
Copy Markdown
Contributor

…-lang

When processing local files or remote URLs, the language was resolved as:

const lang = (options.lang || ext).toLowerCase()

If both options.lang and ext are empty (e.g. Makefile, Dockerfile, or a URL like https://host/Dockerfile), lang becomes an empty string '' which is passed directly to shiki and causes an error.

The stdin code path already handles this correctly:

const lang = options.lang || 'text'

This commit aligns the file/URL path with the same fallback:

const lang = (options.lang || ext || 'text').toLowerCase()

Two regression tests are added covering:

  • A local file with no extension (Makefile)
  • A remote URL whose path has no file extension (Dockerfile)
  • <- Keep this line and put an x between the brackts.

Description

Linked Issues

fixes #

Additional context

…-lang

When processing local files or remote URLs, the language was resolved as:

  const lang = (options.lang || ext).toLowerCase()

If both `options.lang` and `ext` are empty (e.g. `Makefile`, `Dockerfile`,
or a URL like https://host/Dockerfile), `lang` becomes an empty string
`''` which is passed directly to shiki and causes an error.

The stdin code path already handles this correctly:

  const lang = options.lang || 'text'

This commit aligns the file/URL path with the same fallback:

  const lang = (options.lang || ext || 'text').toLowerCase()

Two regression tests are added covering:
- A local file with no extension (Makefile)
- A remote URL whose path has no file extension (Dockerfile)
@netlify

netlify Bot commented Feb 25, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for shiki-next ready!

Name Link
🔨 Latest commit ffb89ad
🔍 Latest deploy log https://app.netlify.com/projects/shiki-next/deploys/699e9ce0329b3c00083312b0
😎 Deploy Preview https://deploy-preview-1248--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.

@netlify

netlify Bot commented Feb 25, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for shiki-matsu ready!

Name Link
🔨 Latest commit ffb89ad
🔍 Latest deploy log https://app.netlify.com/projects/shiki-matsu/deploys/699e9ce09738050008150063
😎 Deploy Preview https://deploy-preview-1248--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.

@codecov

codecov Bot commented Feb 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.26%. Comparing base (4bea1a5) to head (ffb89ad).
⚠️ Report is 56 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1248      +/-   ##
==========================================
+ Coverage   95.25%   95.26%   +0.01%     
==========================================
  Files          92       92              
  Lines        8008     8032      +24     
  Branches     1704     1714      +10     
==========================================
+ Hits         7628     7652      +24     
  Misses        374      374              
  Partials        6        6              

☔ View full report in Codecov by Harness.
📢 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.

@antfu
antfu merged commit c00e573 into shikijs:main Sep 11, 2026
17 checks passed
antfu pushed a commit to SHUBHI-KUMARI/shiki that referenced this pull request Oct 1, 2026
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