Fix params for launching process #724
This commit is contained in:
parent
8527b39fe2
commit
688be6f75a
2
Makefile
2
Makefile
@ -76,7 +76,7 @@ tests: test
|
|||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
@#php artisan database:create --reset
|
@#php artisan database:create --reset
|
||||||
@vendor/bin/phpunit --verbose --debug
|
@vendor/bin/phpunit --verbose
|
||||||
|
|
||||||
.PHONY: phpcs
|
.PHONY: phpcs
|
||||||
phpcs:
|
phpcs:
|
||||||
|
@ -79,6 +79,13 @@ class CreateDatabase extends Command
|
|||||||
*/
|
*/
|
||||||
protected function create_sqlite($dbkey)
|
protected function create_sqlite($dbkey)
|
||||||
{
|
{
|
||||||
|
$dbPath = config($dbkey.'database');
|
||||||
|
|
||||||
|
// Skip if running in memory
|
||||||
|
if ($dbPath === ':memory:') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$exec = 'sqlite3';
|
$exec = 'sqlite3';
|
||||||
if ($this->os->isWindowsLike()) {
|
if ($this->os->isWindowsLike()) {
|
||||||
$exec = 'sqlite3.exe';
|
$exec = 'sqlite3.exe';
|
||||||
@ -89,11 +96,11 @@ class CreateDatabase extends Command
|
|||||||
$this->runCommand($cmd);
|
$this->runCommand($cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists(config($dbkey.'database'))) {
|
if (!file_exists($dbPath)) {
|
||||||
$cmd = [
|
$cmd = [
|
||||||
$exec,
|
$exec,
|
||||||
config($dbkey.'database'),
|
$dbPath,
|
||||||
'""',
|
'".exit"',
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->runCommand($cmd);
|
$this->runCommand($cmd);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Contracts;
|
namespace App\Contracts;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use function is_array;
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,9 +83,9 @@ abstract class Command extends \Illuminate\Console\Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $cmd
|
* @param array|string $cmd
|
||||||
* @param bool $return
|
* @param bool $return
|
||||||
* @param mixed $verbose
|
* @param mixed $verbose
|
||||||
*
|
*
|
||||||
* @throws \Symfony\Component\Process\Exception\RuntimeException
|
* @throws \Symfony\Component\Process\Exception\RuntimeException
|
||||||
* @throws \Symfony\Component\Process\Exception\LogicException
|
* @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
|
public function runCommand($cmd, $return = false, $verbose = true): string
|
||||||
{
|
{
|
||||||
if (!\is_array($cmd)) {
|
if (is_array($cmd)) {
|
||||||
$cmd = explode(' ', $cmd);
|
$cmd = implode(' ', $cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$this->info('Running "'.implode(' ', $cmd).'"');
|
$this->info('Running '.$cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
$val = '';
|
$val = '';
|
||||||
$process = new Process($cmd);
|
$process = Process::fromShellCommandline($cmd);
|
||||||
$process->run(function ($type, $buffer) use ($return, &$val) {
|
$process->run(function ($type, $buffer) use ($return, &$val) {
|
||||||
if ($return) {
|
if ($return) {
|
||||||
$val .= $buffer;
|
$val .= $buffer;
|
||||||
|
Loading…
Reference in New Issue
Block a user