diff --git a/src/Console/Commands/Make/MakeModule.php b/src/Console/Commands/Make/MakeModule.php index 5817e3a..ba330c9 100644 --- a/src/Console/Commands/Make/MakeModule.php +++ b/src/Console/Commands/Make/MakeModule.php @@ -94,13 +94,13 @@ public function handle() $this->setUpStyles(); $this->newLine(); - - $this->ensureModulesDirectoryExists(); - + if ($this->shouldAbortToPublishConfig()) { return 0; } - + + $this->ensureModulesDirectoryExists(); + $this->writeStubs(); $this->updateCoreComposerConfig(); diff --git a/tests/Commands/Make/MakeModuleTest.php b/tests/Commands/Make/MakeModuleTest.php index 673821f..220c367 100644 --- a/tests/Commands/Make/MakeModuleTest.php +++ b/tests/Commands/Make/MakeModuleTest.php @@ -99,4 +99,17 @@ public function test_it_prompts_on_first_module_if_no_custom_namespace_is_set(): $this->assertTrue($fs->isDirectory($this->getBasePath().'/app-modules/test-module-two')); } + + public function test_it_does_not_create_an_empty_directory_if_prompt_on_first_module_if_no_custom_namespace_is_set_is_rejected(): void + { + $fs = $this->filesystem(); + + $this->artisan(MakeModule::class, ['name' => 'test-module']) + ->expectsQuestion('Would you like to cancel and configure your module namespace first?', true) + ->assertExitCode(0); + + Modules::reload(); + + $this->assertFalse($fs->isDirectory($this->getBasePath().'/app-modules/test-module')); + } }