Skip to content

fix(create-sanity): fixes cli bin path#302

Merged
binoy14 merged 1 commit intomainfrom
01-16-fix_create-sanity_fixes_cli_bin_path
Jan 17, 2026
Merged

fix(create-sanity): fixes cli bin path#302
binoy14 merged 1 commit intomainfrom
01-16-fix_create-sanity_fixes_cli_bin_path

Conversation

@binoy14
Copy link
Contributor

@binoy14 binoy14 commented Jan 16, 2026

  1. Fixes bin path lookup for the create package. Uses the path from package.json instead of hard coding it so it works with either cli package.
  2. Moves the create-sanity tests to vitest just so it runs part of the existing test infrastructure

@claude
Copy link

claude bot commented Jan 16, 2026

Claude finished @binoy14's task in 1m 2s —— View job


PR Review

  • Read changed files
  • Analyze for issues
  • Post review findings

Issues Found

1. Path construction incorrect after fileURLToPath (index.js:14)

The code joins cliPkgDir with '..' but cliPkgDir is already the full path to package.json file itself, not its parent directory.

// Line 13-14
const cliPkgDir = fileURLToPath(await moduleResolve('@sanity/cli/package.json', import.meta.url))
const cliDir = join(cliPkgDir, '..')

This creates a path like /path/to/package.json/.. which works but is fragile. Should use dirname(cliPkgDir) instead.

2. Variable naming confusion (index.js:13)

Variable cliPkgDir suggests it's a directory, but it's actually the full path to the package.json file. Rename to cliPkgPath for clarity.

Fix:

import {dirname} from 'node:path'

const cliPkgPath = fileURLToPath(await moduleResolve('@sanity/cli/package.json', import.meta.url))
const cliDir = dirname(cliPkgPath)

const pJson = await readFile(cliPkgPath, 'utf8')

Copy link
Contributor Author

binoy14 commented Jan 16, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@binoy14 binoy14 force-pushed the 01-16-fix_create-sanity_fixes_cli_bin_path branch from 132b8a0 to a1b95f7 Compare January 16, 2026 23:53
@binoy14 binoy14 force-pushed the 01-16-fix_create-sanity_fixes_cli_bin_path branch from a1b95f7 to edbdffb Compare January 16, 2026 23:58
@binoy14 binoy14 marked this pull request as ready for review January 17, 2026 00:00
@binoy14 binoy14 requested a review from a team as a code owner January 17, 2026 00:00
@binoy14 binoy14 requested review from colepeters and rexxars and removed request for a team January 17, 2026 00:00
@github-actions
Copy link

github-actions bot commented Jan 17, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 70.72% 5492 / 7765
🔵 Statements 70.07% 5633 / 8038
🔵 Functions 57.71% 819 / 1419
🔵 Branches 58.7% 2457 / 4185
File CoverageNo changed files found.
Generated in workflow #1559 for commit edbdffb by the Vitest Coverage Report Action

Copy link
Member

@rexxars rexxars left a comment

Choose a reason for hiding this comment

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

Could likely benefit from a bit more explicit path resolution here (eg using dirname and resolve() etc), but since it's not going to be printed it's not the end of the world.

@binoy14
Copy link
Contributor Author

binoy14 commented Jan 17, 2026

I'll do a followup

@binoy14 binoy14 merged commit c145526 into main Jan 17, 2026
33 of 35 checks passed
@binoy14 binoy14 deleted the 01-16-fix_create-sanity_fixes_cli_bin_path branch January 17, 2026 00:45
@squiggler-legacy squiggler-legacy bot mentioned this pull request Jan 17, 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