Skip to content

Commit 71e7b00

Browse files
yeldarbyclaude
andcommitted
Default the Node.js winget prompt to yes
User feedback: when the installer asks "Install Node.js LTS now via winget (OpenJS.NodeJS.LTS, no admin)?" the default should be yes, not no. The alternative when the user just hits enter today is "installer aborts with no progress, user manually downloads Node from nodejs.org, re-runs the installer" — strictly worse than letting us run a no-admin winget install. Saying no is still one keystroke (`n`). Adds an optional default-answer argument to Confirm-Rf (PowerShell) / rf::confirm (bash) so callers can opt into the inverted "[Y/n]" prompt with empty-input = yes. Only the Node prompt opts in. The existing "Remove Roboflow from: ..." uninstall confirms keep the safe legacy "[y/N]" default-no (no -DefaultAnswer flag passed). Pester Prereq.Tests.ps1: 6/6 green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 99cfc4b commit 71e7b00

4 files changed

Lines changed: 34 additions & 7 deletions

File tree

installer/lib/common.ps1

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,19 @@ function Invoke-RfDie {
4545
}
4646

4747
function Confirm-Rf {
48-
param([string]$Prompt)
48+
param(
49+
[string]$Prompt,
50+
# 'y' means the prompt shows "[Y/n]" and enter without input is yes;
51+
# 'n' (default) keeps the legacy "[y/N]" with no-on-enter.
52+
[ValidateSet('y', 'n')]
53+
[string]$DefaultAnswer = 'n'
54+
)
4955
if ($Script:RfYes) { return $true }
56+
if ($DefaultAnswer -eq 'y') {
57+
$reply = Read-Host "$Prompt [Y/n]"
58+
if ([string]::IsNullOrEmpty($reply)) { return $true }
59+
return $reply -notmatch '^[Nn]'
60+
}
5061
$reply = Read-Host "$Prompt [y/N]"
5162
return $reply -match '^[Yy]'
5263
}

installer/lib/common.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,22 @@ rf::die() {
4141
exit "${RF_EXIT_CODE:-1}"
4242
}
4343

44-
# rf::confirm <prompt> — returns 0 for yes, 1 for no. Auto-yes if RF_YES=1.
44+
# rf::confirm <prompt> [default] — returns 0 for yes, 1 for no.
45+
# Auto-yes if RF_YES=1. Default arg "y" inverts the prompt to "[Y/n]" and
46+
# treats an empty answer as yes; default "n" (or omitted) is the legacy
47+
# "[y/N]" with no-on-enter.
4548
rf::confirm() {
4649
if [[ "${RF_YES:-0}" == "1" ]]; then
4750
return 0
4851
fi
49-
local prompt="$1" reply
50-
read -r -p "$prompt [y/N] " reply </dev/tty
51-
[[ "$reply" =~ ^[Yy] ]]
52+
local prompt="$1" default="${2:-n}" reply
53+
if [[ "$default" == "y" ]]; then
54+
read -r -p "$prompt [Y/n] " reply </dev/tty
55+
[[ -z "$reply" || "$reply" =~ ^[Yy] ]]
56+
else
57+
read -r -p "$prompt [y/N] " reply </dev/tty
58+
[[ "$reply" =~ ^[Yy] ]]
59+
fi
5260
}
5361

5462
# rf::prompt <prompt> [default] — read a line from /dev/tty.

installer/lib/prereq.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ function Confirm-RfNpxAvailable {
5555
}
5656

5757
if (-not $Script:RfYes) {
58-
if (-not (Confirm-Rf -Prompt "Install Node.js LTS now via $(Get-RfNodeInstallMethodLabel)?")) {
58+
# Default to yes: the alternative is "installer aborts with no
59+
# progress, user manually installs Node, re-runs," which is worse
60+
# than a winget install in every case where the user didn't have a
61+
# specific reason to refuse. Refusing is still one keystroke (`n`).
62+
if (-not (Confirm-Rf -Prompt "Install Node.js LTS now via $(Get-RfNodeInstallMethodLabel)?" -DefaultAnswer 'y')) {
5963
Write-RfErr 'Node.js is required to proceed. Install it from https://nodejs.org and re-run agents.ps1.'
6064
return $false
6165
}

installer/lib/prereq.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ rf::prereq::ensure_npx() {
6767
fi
6868

6969
if [[ "${RF_YES:-0}" != "1" ]]; then
70-
if ! rf::confirm "Install Node.js LTS now via $(rf::prereq::node_method_label)?"; then
70+
# Default to yes -- see the PowerShell equivalent for rationale:
71+
# refusing means the installer aborts and the user has to install
72+
# Node manually and re-run, which is worse than just letting us
73+
# install it. Saying no is still one keystroke (`n`).
74+
if ! rf::confirm "Install Node.js LTS now via $(rf::prereq::node_method_label)?" y; then
7175
rf::err "Node.js is required to proceed. Install it from https://nodejs.org and re-run agents.sh."
7276
return 1
7377
fi

0 commit comments

Comments
 (0)