mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
feat: improves init plugin
This commit is contained in:
@ -63,10 +63,6 @@ final class Init implements HandlesArguments
|
|||||||
|
|
||||||
private function init(): void
|
private function init(): void
|
||||||
{
|
{
|
||||||
if ($this->isLaravelInstalled()) {
|
|
||||||
exit($this->initLaravel());
|
|
||||||
}
|
|
||||||
|
|
||||||
$testsBaseDir = "{$this->testSuite->rootPath}/tests";
|
$testsBaseDir = "{$this->testSuite->rootPath}/tests";
|
||||||
|
|
||||||
if (! is_dir($testsBaseDir)) {
|
if (! is_dir($testsBaseDir)) {
|
||||||
@ -79,7 +75,12 @@ final class Init implements HandlesArguments
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
foreach (self::STUBS as $from => $to) {
|
foreach (self::STUBS as $from => $to) {
|
||||||
$fromPath = __DIR__."/../../stubs/init/{$from}";
|
if ($this->isLaravelInstalled()) {
|
||||||
|
$fromPath = __DIR__."/../../stubs/init-laravel/{$from}";
|
||||||
|
} else {
|
||||||
|
$fromPath = __DIR__."/../../stubs/init/{$from}";
|
||||||
|
}
|
||||||
|
|
||||||
$toPath = "{$this->testSuite->rootPath}/{$to}";
|
$toPath = "{$this->testSuite->rootPath}/{$to}";
|
||||||
|
|
||||||
if (file_exists($toPath)) {
|
if (file_exists($toPath)) {
|
||||||
@ -106,37 +107,6 @@ final class Init implements HandlesArguments
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function initLaravel(): int
|
|
||||||
{
|
|
||||||
$command = [
|
|
||||||
'composer', 'require',
|
|
||||||
'pestphp/pest-plugin-laravel 2.x-dev',
|
|
||||||
'--dev',
|
|
||||||
];
|
|
||||||
|
|
||||||
$result = (new Process($command, $this->testSuite->rootPath, ['COMPOSER_MEMORY_LIMIT' => '-1']))
|
|
||||||
->setTimeout(null)
|
|
||||||
->run(function ($type, $output): void {
|
|
||||||
$this->output->write($output);
|
|
||||||
});
|
|
||||||
|
|
||||||
if ($result > 0) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
$command = [
|
|
||||||
'php', 'artisan',
|
|
||||||
'pest:install',
|
|
||||||
'--ansi', '--no-interaction',
|
|
||||||
];
|
|
||||||
|
|
||||||
return (new Process($command, $this->testSuite->rootPath, ['COMPOSER_MEMORY_LIMIT' => '-1']))
|
|
||||||
->setTimeout(null)
|
|
||||||
->run(function ($type, $output): void {
|
|
||||||
$this->output->write($output);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if laravel is installed through Composer
|
* Checks if laravel is installed through Composer
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user