Skip to content

Commit b5d2669

Browse files
rexxarsclaude
andcommitted
fix(init): guard against missing sanity binary before dataset import
Add fs.access check before spawning the sanity binary for dataset import. Gives a clear error message instead of a raw ENOENT if dependencies weren't installed correctly. Also fix misleading vitest config comment. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 020c660 commit b5d2669

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/@sanity/cli/src/actions/init/initStudio.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import fs from 'node:fs/promises'
12
import path from 'node:path'
23
import {styleText} from 'node:util'
34

@@ -108,6 +109,14 @@ export async function initStudio({
108109
// Spawn the project's own sanity binary for dataset import.
109110
// The full CLI is available as a project dependency after scaffoldAndInstall.
110111
const sanityBin = path.join(outputPath, 'node_modules', '.bin', 'sanity')
112+
try {
113+
await fs.access(sanityBin)
114+
} catch {
115+
throw new InitError(
116+
`Could not find sanity binary at "${sanityBin}". ` +
117+
'Dependencies may not have been installed correctly.',
118+
)
119+
}
111120
await execa(
112121
sanityBin,
113122
[

packages/create-sanity/vitest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineConfig({
66
exclude: ['**/dist/**', '**/test/**', '**/*.{test,spec}.{js,ts}'],
77
provider: 'istanbul',
88
},
9-
disableConsoleIntercept: true, // helps oclif test helpers
9+
disableConsoleIntercept: true, // tests spawn subprocesses that write to stdout/stderr
1010
environment: 'node',
1111
exclude: ['**/node_modules/**', '**/dist/**'],
1212
globals: false,

0 commit comments

Comments
 (0)