Skip to content

Hook installation generates invalid file paths from JSR #9

@drernie

Description

@drernie

Description

When installing deno-hooks from JSR using deno run -A jsr:@theswanfactory/deno-hooks/install, the generated git hook files contain invalid file paths.

Steps to Reproduce

  1. Add deno-hooks as a dependency in deno.json:
"imports": {
  "deno-hooks": "jsr:@theswanfactory/deno-hooks@^0.2.0"
}
  1. Run the installer:
deno run -A deno-hooks
  1. Check the generated hook file:
cat .git/hooks/pre-commit

Expected Behavior

The hook should contain a valid path to the JSR-installed module, such as:

exec deno run -A "jsr:@theswanfactory/deno-hooks@0.2.0/src/run.ts" "pre-commit" "$@"

Or use the import map alias:

exec deno run -A "deno-hooks/run.ts" "pre-commit" "$@"

Actual Behavior

The generated hook contains an invalid absolute path:

exec deno run -A "/@theswanfactory/deno-hooks/0.2.0/src/run.ts" "pre-commit" "$@"

Error When Hook Runs

error: Module not found "file:///@theswanfactory/deno-hooks/0.2.0/src/run.ts"

Environment

  • deno-hooks version: 0.2.0
  • Deno version: (latest)
  • OS: macOS (Darwin 24.6.0)

Workaround

Currently using git commit --no-verify to bypass hooks.

Suggested Fix

The installer should detect when running from JSR and generate hook paths that use either:

  1. The full JSR specifier: jsr:@theswanfactory/deno-hooks@0.2.0/src/run.ts
  2. The import map alias if available: deno-hooks/run.ts
  3. The actual filesystem path from the Deno cache

The path generation logic likely needs to handle import.meta.url differently when the module is loaded from JSR vs a local filesystem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions