diff --git a/src/StarterKits/InstallableModule.php b/src/StarterKits/InstallableModule.php index fb42f5503b4..0beb51462ae 100644 --- a/src/StarterKits/InstallableModule.php +++ b/src/StarterKits/InstallableModule.php @@ -74,11 +74,28 @@ protected function installFiles(): self { $this->installableFiles()->each(function ($toPath, $fromPath) { $this->installFile($fromPath, $toPath, $this->installer->console()); + $this->loadInstalledConfig($toPath); }); return $this; } + /** + * Load installed config file into the running app, so later install steps see it. + */ + private function loadInstalledConfig(string $path): void + { + $configPath = Path::tidy(config_path()).'/'; + + if (! Str::startsWith($path, $configPath) || ! Str::endsWith($path, '.php')) { + return; + } + + $key = Str::of($path)->after($configPath)->beforeLast('.php')->replace('/', '.')->toString(); + + config()->set($key, array_merge(config($key, []), require $path)); + } + /** * Install starter kit module dependencies. */ diff --git a/tests/StarterKits/InstallTest.php b/tests/StarterKits/InstallTest.php index 29969ee5be6..fff7b9bbb71 100644 --- a/tests/StarterKits/InstallTest.php +++ b/tests/StarterKits/InstallTest.php @@ -118,6 +118,20 @@ public function it_installs_from_export_paths() $this->assertFileHasContent('bobsled_pics', config_path('filesystems.php')); } + #[Test] + public function it_loads_installed_config_files_into_the_running_app() + { + $this->files->put($this->preparePath($this->kitRepoPath('config/statamic/hockey.php')), " 'calgary'];"); + + $this->assertNull(config('filesystems.disks.bobsled_pics')); + $this->assertNull(config('statamic.hockey')); + + $this->installCoolRunnings(); + + $this->assertEquals('local', config('filesystems.disks.bobsled_pics.driver')); + $this->assertEquals('calgary', config('statamic.hockey.rink')); + } + #[Test] public function it_installs_from_github() {