Skip to content

Commit 3947a39

Browse files
committed
fix: patch up prompt name/defaults error on single question prompts
1 parent 7f9f7bb commit 3947a39

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Sprout/Prompt.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ public function ask()
7979
return [];
8080
}
8181

82-
$this->answers[$prompt['name']] = $answer;
82+
if (isset($prompt['name'])) {
83+
$this->answers[$prompt['name']] = $answer;
84+
}
8385
}
8486

8587
if ($this->singlePrompt) {
@@ -210,7 +212,7 @@ protected function renderTextPrompt($prompt, $rerender = true)
210212
return;
211213
}
212214

213-
$output = $this->currentInput ?: "\033[90m{$prompt['default']}\033[0m";
215+
$output = $this->currentInput ?: (isset($prompt['default']) ? "\033[90m{$prompt['default']}\033[0m" : '');
214216

215217
sprout()->style()->write(
216218
"\033[36m?\033[0m \033[1;1m{$prompt['message']}:\033[0m \033[90m›\033[0m $output" . PHP_EOL

0 commit comments

Comments
 (0)