Skip to content

Commit ac13df4

Browse files
committed
feat: copy over sample wp-config file if there's no wp-config file
1 parent b6ce48b commit ac13df4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Build/ModifyWordPressConfigurationStep.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,13 @@ public function isNeeded(string $environment, ProjectConfiguration $projectConfi
7272
public function perform(string $environment, ProjectConfiguration $projectConfiguration)
7373
{
7474
$environment = (array) $projectConfiguration->getEnvironment($environment);
75+
$sampleWpConfigFile = $this->buildDirectory.'/wp-config-sample.php';
7576
$wpConfigFile = $this->buildDirectory.'/wp-config.php';
7677

77-
if (!$this->filesystem->exists($wpConfigFile)) {
78-
throw new RuntimeException('No wp-config.php found in the build directory');
78+
if (!$this->filesystem->exists($wpConfigFile) && $this->filesystem->exists($sampleWpConfigFile)) {
79+
$this->filesystem->copy($sampleWpConfigFile, $wpConfigFile);
80+
} elseif (!$this->filesystem->exists($wpConfigFile) && !$this->filesystem->exists($sampleWpConfigFile)) {
81+
throw new RuntimeException('No wp-config.php or wp-config-sample.php found in the build directory');
7982
}
8083

8184
$wpConfig = file($wpConfigFile, FILE_IGNORE_NEW_LINES);

0 commit comments

Comments
 (0)