diff --git a/Makefile b/Makefile index fea20e43..4366a0b0 100644 --- a/Makefile +++ b/Makefile @@ -76,7 +76,7 @@ tests: test .PHONY: test test: @#php artisan database:create --reset - @vendor/bin/phpunit --verbose --debug + @vendor/bin/phpunit --verbose .PHONY: phpcs phpcs: diff --git a/app/Console/Commands/CreateDatabase.php b/app/Console/Commands/CreateDatabase.php index aa99a9cc..066ed3e8 100644 --- a/app/Console/Commands/CreateDatabase.php +++ b/app/Console/Commands/CreateDatabase.php @@ -79,6 +79,13 @@ class CreateDatabase extends Command */ protected function create_sqlite($dbkey) { + $dbPath = config($dbkey.'database'); + + // Skip if running in memory + if ($dbPath === ':memory:') { + return; + } + $exec = 'sqlite3'; if ($this->os->isWindowsLike()) { $exec = 'sqlite3.exe'; @@ -89,11 +96,11 @@ class CreateDatabase extends Command $this->runCommand($cmd); } - if (!file_exists(config($dbkey.'database'))) { + if (!file_exists($dbPath)) { $cmd = [ $exec, - config($dbkey.'database'), - '""', + $dbPath, + '".exit"', ]; $this->runCommand($cmd); diff --git a/app/Contracts/Command.php b/app/Contracts/Command.php index df548fda..aa44de6d 100644 --- a/app/Contracts/Command.php +++ b/app/Contracts/Command.php @@ -3,6 +3,7 @@ namespace App\Contracts; use Illuminate\Support\Facades\Log; +use function is_array; use Symfony\Component\Process\Process; /** @@ -82,9 +83,9 @@ abstract class Command extends \Illuminate\Console\Command } /** - * @param $cmd - * @param bool $return - * @param mixed $verbose + * @param array|string $cmd + * @param bool $return + * @param mixed $verbose * * @throws \Symfony\Component\Process\Exception\RuntimeException * @throws \Symfony\Component\Process\Exception\LogicException @@ -93,16 +94,16 @@ abstract class Command extends \Illuminate\Console\Command */ public function runCommand($cmd, $return = false, $verbose = true): string { - if (!\is_array($cmd)) { - $cmd = explode(' ', $cmd); + if (is_array($cmd)) { + $cmd = implode(' ', $cmd); } if ($verbose) { - $this->info('Running "'.implode(' ', $cmd).'"'); + $this->info('Running '.$cmd); } $val = ''; - $process = new Process($cmd); + $process = Process::fromShellCommandline($cmd); $process->run(function ($type, $buffer) use ($return, &$val) { if ($return) { $val .= $buffer;