Skip to content

fix(cli): detect Deno JSR cli entrypoint#1472

Open
rohan-patnaik wants to merge 1 commit into
google:mainfrom
rohan-patnaik:fix-deno-jsr-main
Open

fix(cli): detect Deno JSR cli entrypoint#1472
rohan-patnaik wants to merge 1 commit into
google:mainfrom
rohan-patnaik:fix-deno-jsr-main

Conversation

@rohan-patnaik
Copy link
Copy Markdown

@rohan-patnaik rohan-patnaik commented May 22, 2026

Fixes #1383.

What changed

isMain() now recognizes Deno JSR executions where the main module is reported as jsr:@webpod/zx, jsr:@webpod/zx/., or jsr:@webpod/zx/cli.

This keeps the existing Node/file-url behavior unchanged, but lets the CLI autorun when zx is launched through its JSR entrypoint.

Why

When running through JSR, Deno does not always expose the CLI as a local file path. The old isMain() check only handled local file URLs or import.meta.main, so deno run jsr:@webpod/zx could import the module without entering the CLI path.

Usage demo

import { isMain } from 'zx/cli'

// Simulates Deno reporting the JSR package root as the main module.
globalThis.Deno = { mainModule: 'jsr:@webpod/zx' }
console.log(isMain('jsr:@webpod/zx/cli')) // true
  • Setup Set the latest Node.js LTS version.
  • Build: I’ve run npm build before committing and verified the bundle updates correctly.
  • Tests: I’ve run focused tests and size checks. Added regression coverage for the JSR main-module cases.
  • Docs: Not needed; this is a CLI entrypoint fix covered by tests.
  • Sign Commits have verified signatures and follow conventional commits spec.
  • CoC: My changes follow the project’s coding guidelines and Code of Conduct.
  • Review: This PR represents original work and is not solely generated by AI tools.

@rohan-patnaik rohan-patnaik marked this pull request as ready for review May 22, 2026 08:57
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.

Why doesdeno run not use jsr:@webpod/zx?

1 participant