Skip to content

Commit 35a901c

Browse files
mtorpclaude
andcommitted
fix: default to cwd when --reach is used without explicit target
When `socket scan create --reach` is run without an explicit target path, the CLI previously relied on an interactive prompt to ask the user to confirm the current directory. In non-TTY environments (e.g. Jenkins CI), the select() prompt silently fails because wrapPrompt swallows non-TypeError errors, causing suggestTarget() to return [] and all reach validations to fail with confusing "Input error: At least one TARGET (missing)" errors. Now falls back to '.' (cwd) when the prompt returns empty, preserving the interactive prompt for TTY users while gracefully handling non-TTY environments. Also bumps @coana-tech/cli to 14.12.200 and CLI version to 1.1.74. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 572fbcc commit 35a901c

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/commands/scan/cmd-scan-create.mts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -381,21 +381,22 @@ async function run(
381381
let updatedInput = false
382382

383383
// Accept zero or more paths. Default to cwd() if none given.
384-
// Note: cli.input is always an array (even if empty), so || [cwd] never
385-
// fires because [] is truthy. Use .length check instead.
386384
let targets = cli.input.length ? cli.input : []
387385

388-
if (!targets.length && reach) {
389-
// --reach requires exactly one directory target; default to cwd rather
390-
// than relying on an interactive prompt that fails in non-TTY environments
391-
// such as Jenkins CI (the select() prompt silently returns undefined when
392-
// stdin is not a TTY, causing all downstream validations to fail).
393-
targets = ['.']
394-
} else if (!targets.length && !dryRun && interactive) {
386+
if (!targets.length && !dryRun && interactive) {
395387
targets = await suggestTarget()
396388
updatedInput = true
397389
}
398390

391+
// Fallback: if targets is still empty after the interactive prompt (e.g. the
392+
// select() prompt silently fails in non-TTY environments like Jenkins CI
393+
// because wrapPrompt swallows non-TypeError errors and returns undefined),
394+
// default to '.' so that downstream validations don't fail with confusing
395+
// "At least one TARGET (missing)" errors.
396+
if (!targets.length && !dryRun) {
397+
targets = ['.']
398+
}
399+
399400
// We're going to need an api token to suggest data because those suggestions
400401
// must come from data we already know. Don't error on missing api token yet.
401402
// If the api-token is not set, ignore it for the sake of suggestions.

0 commit comments

Comments
 (0)