Skip to content

Commit ba2c0b6

Browse files
committed
Don't show feedback when prompts are not used
1 parent c74b8ba commit ba2c0b6

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

packages/framework/src/Console/Commands/PublishViewsCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function handle(): int
4242

4343
$selected = ($this->argument('category') ?? $this->promptForCategory()) ?: 'all';
4444

45-
if ($selected !== 'all' && (bool) $this->argument('category') === false) {
45+
if ($selected !== 'all' && (bool) $this->argument('category') === false && ConsoleHelper::canUseLaravelPrompts($this->input)) {
4646
$this->infoComment(sprintf('Selected category [%s]', $selected));
4747
}
4848

packages/framework/tests/Feature/Commands/PublishViewsCommandTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public function testCanSelectGroupWithQuestion()
7777

7878
$this->artisan('publish:views')
7979
->expectsQuestion('Which category do you want to publish?', '<comment>layouts</comment>: Shared layout views, such as the app layout, navigation menu, and Markdown page templates')
80-
->expectsOutput('Selected category [layouts]')
8180
->expectsOutput('Published all [layout] files to [resources/views/vendor/hyde/layouts]')
8281
->assertExitCode(0);
8382

@@ -207,6 +206,26 @@ public function testInteractiveSelectionWithComplexToggles()
207206
$this->assertDirectoryDoesNotExist(Hyde::path('resources/views/vendor/hyde/components'));
208207
}
209208

209+
public function testCanSelectGroupWithQuestionAndPrompts()
210+
{
211+
if (windows_os()) {
212+
$this->markTestSkipped('Test is not applicable on Windows systems.');
213+
}
214+
215+
$this->artisan('publish:views')
216+
->expectsQuestion('Which category do you want to publish?', '<comment>layouts</comment>: Shared layout views, such as the app layout, navigation menu, and Markdown page templates')
217+
->expectsOutput('Selected category [layouts]')
218+
->expectsQuestion('Select the files you want to publish', (is_dir(Hyde::path('packages')) ? 'packages' : 'vendor/hyde').'/framework/resources/views/layouts/app.blade.php')
219+
->expectsOutput('Published selected file to [resources/views/vendor/hyde/layouts/app.blade.php]')
220+
->assertExitCode(0);
221+
222+
$this->assertFileExists(Hyde::path('resources/views/vendor/hyde/layouts/app.blade.php'));
223+
224+
$this->assertFileDoesNotExist(Hyde::path('resources/views/vendor/hyde/layouts/page.blade.php'));
225+
$this->assertDirectoryDoesNotExist(Hyde::path('resources/views/vendor/hyde/components'));
226+
$this->assertFileDoesNotExist(Hyde::path('resources/views/vendor/hyde/components/article-excerpt.blade.php'));
227+
}
228+
210229
protected function executePublishViewsCommand(): BufferedOutput
211230
{
212231
$command = (new PublishViewsCommand());

0 commit comments

Comments
 (0)