Skip to content

Commit 3e5c96d

Browse files
committed
fix: patch up default selection on update
1 parent 993d008 commit 3e5c96d

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/CreateCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ protected function handle(): int
5252
if (sprout()->run('php ' . dirname(__DIR__) . '/bin/leaf update') === 0) {
5353
$this->writeln("Leaf CLI updated successfully, building your app...\n");
5454

55-
return sprout()->run('php ' . implode(' ', array_map('escapeshellarg', (array) $_SERVER['argv'])));
55+
passthru('php ' . implode(' ', array_map('escapeshellarg', (array) $_SERVER['argv'])), $exitCode);
56+
57+
return $exitCode;
5658
} else {
5759
$this->writeln("❌ Leaf CLI update failed, please try again later\n");
5860
$this->writeln("⚙️ Creating app with current version...\n");

tests/commands.test.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@
101101
expect($theme['require']['leafs/leaf'])->toStartWith('^');
102102
});
103103

104+
test('the post-update re-exec keeps the terminal', function () {
105+
$source = file_get_contents(dirname(__DIR__) . '/src/CreateCommand.php');
106+
107+
// a piped re-exec (sprout()->run) can't prompt — the fresh cli then
108+
// answers every question with its default and scaffolds the wrong app
109+
expect($source)->toContain("passthru('php ' . implode")
110+
->and($source)->not->toContain("return sprout()->run('php ' . implode");
111+
});
112+
104113
test('view:install pins every vite-adjacent npm package', function () {
105114
$source = file_get_contents(dirname(__DIR__) . '/src/ViewInstallCommand.php');
106115

0 commit comments

Comments
 (0)