Skip to content

Commit 6494e6d

Browse files
committed
fix: condition failed if we had a bedrock project and no global wp-cli
1 parent 07fe09a commit 6494e6d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Command/Project/InitializeProjectCommand.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,15 @@ private function addEnvironmentDatabaseNodes(Collection $environments, ConsoleOu
196196
*/
197197
private function checkForWordPress(ConsoleOutput $output, string $projectType)
198198
{
199-
if (!in_array($projectType, ['bedrock', 'wordpress']) || !WpCli::isInstalledGlobally() || WpCli::isWordPressInstalled() || !$output->confirm('WordPress wasn\'t detected in the project directory. Would you like to download it?')) {
199+
if (!$this->isWordPressDownloadable($projectType) || !$output->confirm('WordPress wasn\'t detected in the project directory. Would you like to download it?')) {
200200
return;
201201
}
202202

203203
if ('bedrock' === $projectType) {
204+
$output->info('Creating new Bedrock project');
204205
Process::runShellCommandline('composer create-project roots/bedrock .');
205206
} elseif ('wordpress' === $projectType) {
207+
$output->info('Downloading WordPress using WP-CLI');
206208
WpCli::downloadWordPress();
207209
}
208210

@@ -281,4 +283,15 @@ private function isPluginInstalled(string $projectType): bool
281283
return ('wordpress' === $projectType && WpCli::isYmirPluginInstalled())
282284
|| ('bedrock' === $projectType && false !== strpos((string) file_get_contents('./composer.json'), 'ymirapp/wordpress-plugin'));
283285
}
286+
287+
/**
288+
* Checks if we're able to download WordPress.
289+
*/
290+
private function isWordPressDownloadable(string $projectType): bool
291+
{
292+
return in_array($projectType, ['bedrock', 'wordpress'])
293+
&& !WpCli::isWordPressInstalled()
294+
&& (('wordpress' === $projectType && WpCli::isInstalledGlobally())
295+
|| ('bedrock' === $projectType && !(new \FilesystemIterator($this->projectDirectory))->valid()));
296+
}
284297
}

0 commit comments

Comments
 (0)