Skip to content

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

Open
VeerShah41 wants to merge 1 commit intoshikijs:mainfrom
VeerShah41:fix/cli-extensionless-file-lang-fallback
Open

fix(cli): fall back to 'text' when file/URL has no extension and no -…#1248
VeerShah41 wants to merge 1 commit intoshikijs:mainfrom
VeerShah41:fix/cli-extensionless-file-lang-fallback

Conversation

@VeerShah41
Copy link
Copy Markdown

…-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
Copy link
Copy Markdown

netlify bot commented Feb 25, 2026

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
Copy link
Copy Markdown

netlify bot commented Feb 25, 2026

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
Copy link
Copy Markdown

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.26%. Comparing base (4bea1a5) to head (ffb89ad).
⚠️ Report is 9 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 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.

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.

1 participant