Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/StarterKits/InstallableModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
14 changes: 14 additions & 0 deletions tests/StarterKits/InstallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')), "<?php\n\nreturn ['rink' => '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()
{
Expand Down
Loading