Skip to content

Commit 390598f

Browse files
mtorpclaude
andauthored
fix: default to cwd when --reach is used without explicit target (#1121)
* 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 defaults to '.' (cwd) when --reach is used without a target, which is consistent with --reach requiring exactly one directory target. 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> * 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> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9692a36 commit 390598f

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

7+
## [1.1.74](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.74) - 2026-03-19
8+
9+
### Fixed
10+
- Fixed `socket scan create --reach` failing with input validation errors when no explicit target is passed. In non-TTY environments (e.g. Jenkins CI), the interactive prompt to confirm the current directory would silently fail, causing all reach validations to error. Now defaults to `.` (cwd) when `--reach` is used without a target.
11+
12+
### Changed
13+
- Updated the Coana CLI to v `14.12.200`.
14+
715
## [1.1.73](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.73) - 2026-03-13
816

917
### Changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "socket",
3-
"version": "1.1.73",
3+
"version": "1.1.74",
44
"description": "CLI for Socket.dev",
55
"homepage": "https://github.com/SocketDev/socket-cli",
66
"license": "MIT AND OFL-1.1",
@@ -97,7 +97,7 @@
9797
"@babel/preset-typescript": "7.27.1",
9898
"@babel/runtime": "7.28.4",
9999
"@biomejs/biome": "2.2.4",
100-
"@coana-tech/cli": "14.12.197",
100+
"@coana-tech/cli": "14.12.200",
101101
"@cyclonedx/cdxgen": "12.1.2",
102102
"@dotenvx/dotenvx": "1.49.0",
103103
"@eslint/compat": "1.3.2",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

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

383383
// Accept zero or more paths. Default to cwd() if none given.
384-
let targets = cli.input || [cwd]
384+
let targets = cli.input.length ? cli.input : []
385385

386386
if (!targets.length && !dryRun && interactive) {
387387
targets = await suggestTarget()
388388
updatedInput = true
389389
}
390390

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+
391400
// We're going to need an api token to suggest data because those suggestions
392401
// must come from data we already know. Don't error on missing api token yet.
393402
// If the api-token is not set, ignore it for the sake of suggestions.

0 commit comments

Comments
 (0)