call the .exe versions if on Windows

This commit is contained in:
Nabeel Shahzad 2017-12-05 14:59:31 -06:00
parent dc5b8a4569
commit 7b88802d7b
3 changed files with 93 additions and 25 deletions

View File

@ -12,10 +12,12 @@ class CreateDatabase extends Command
{
protected $signature = 'database:create {--reset} {--conn=?}';
protected $description = 'Create a database';
protected $os;
public function __construct()
{
parent::__construct();
$this->os = new \Tivie\OS\Detector();
}
protected function runCommand($cmd)
@ -33,10 +35,19 @@ class CreateDatabase extends Command
echo $proc->getOutput();
}
/**
* create the mysql database
* @param $dbkey
*/
protected function create_mysql($dbkey)
{
$exec = 'mysql';
if($this->os->isWindowsLike()) {
$exec .= '.exe';
}
$mysql_cmd = [
'mysql',
$exec,
'-u' . config($dbkey . 'username'),
'-h' . config($dbkey . 'host'),
'-P' . config($dbkey . 'port'),
@ -65,15 +76,24 @@ class CreateDatabase extends Command
$this->runCommand($cmd);
}
/**
* Create the sqlite database
* @param $dbkey
*/
protected function create_sqlite($dbkey)
{
$exec = 'sqlite3';
if ($this->os->isWindowsLike()) {
$exec .= 'sqlite3';
}
if ($this->option('reset')) {
$cmd = ['rm', '-rf', config($dbkey . 'database')];
$this->runCommand($cmd);
}
$cmd = [
'sqlite3',
$exec,
config($dbkey . 'database'),
'""',
];

View File

@ -45,7 +45,8 @@
"scriptfusion/phpunit-immediate-exception-printer": "1.3.0",
"nwidart/laravel-modules": "2.6.0",
"sebastiaanluca/laravel-helpers": "1.0.2",
"nabeel/laravel-installer": "dev-master"
"nabeel/laravel-installer": "dev-master",
"tivie/php-os-detector": "1.1.0"
},
"require-dev": {
"phpunit/phpunit": "6.4.0",

91
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "084911a53c061e6d07887e1447a07607",
"content-hash": "df8634a2bf7eeab2eab737e82bd163bb",
"packages": [
{
"name": "anlutro/l4-settings",
@ -4533,16 +4533,16 @@
},
{
"name": "symfony/console",
"version": "v3.4.0",
"version": "v3.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "9468ad3fba3a5e1f0dc12a96e50e84cddb923cf0"
"reference": "2cdef78de8f54f68ff16a857e710e7302b47d4c7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/9468ad3fba3a5e1f0dc12a96e50e84cddb923cf0",
"reference": "9468ad3fba3a5e1f0dc12a96e50e84cddb923cf0",
"url": "https://api.github.com/repos/symfony/console/zipball/2cdef78de8f54f68ff16a857e710e7302b47d4c7",
"reference": "2cdef78de8f54f68ff16a857e710e7302b47d4c7",
"shasum": ""
},
"require": {
@ -4598,7 +4598,7 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2017-11-29T13:28:14+00:00"
"time": "2017-12-02T18:20:11+00:00"
},
{
"name": "symfony/css-selector",
@ -4655,7 +4655,7 @@
},
{
"name": "symfony/debug",
"version": "v3.4.0",
"version": "v3.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
@ -4830,7 +4830,7 @@
},
{
"name": "symfony/finder",
"version": "v3.4.0",
"version": "v3.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
@ -4879,7 +4879,7 @@
},
{
"name": "symfony/http-foundation",
"version": "v3.4.0",
"version": "v3.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
@ -4933,16 +4933,16 @@
},
{
"name": "symfony/http-kernel",
"version": "v3.4.0",
"version": "v3.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
"reference": "2df856c9dd8a1e1f11439b12e58c474afc1aac0d"
"reference": "b101bb29071163563d4c8b537b35845eaf909235"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/2df856c9dd8a1e1f11439b12e58c474afc1aac0d",
"reference": "2df856c9dd8a1e1f11439b12e58c474afc1aac0d",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/b101bb29071163563d4c8b537b35845eaf909235",
"reference": "b101bb29071163563d4c8b537b35845eaf909235",
"shasum": ""
},
"require": {
@ -5017,7 +5017,7 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com",
"time": "2017-11-30T16:56:05+00:00"
"time": "2017-12-04T23:05:00+00:00"
},
{
"name": "symfony/inflector",
@ -5396,7 +5396,7 @@
},
{
"name": "symfony/process",
"version": "v3.4.0",
"version": "v3.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
@ -5445,7 +5445,7 @@
},
{
"name": "symfony/property-access",
"version": "v3.4.0",
"version": "v3.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/property-access.git",
@ -5513,7 +5513,7 @@
},
{
"name": "symfony/routing",
"version": "v3.4.0",
"version": "v3.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
@ -5591,7 +5591,7 @@
},
{
"name": "symfony/serializer",
"version": "v3.4.0",
"version": "v3.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/serializer.git",
@ -5669,7 +5669,7 @@
},
{
"name": "symfony/translation",
"version": "v3.4.0",
"version": "v3.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
@ -5737,7 +5737,7 @@
},
{
"name": "symfony/var-dumper",
"version": "v3.4.0",
"version": "v3.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
@ -5949,6 +5949,54 @@
"homepage": "https://github.com/tijsverkoyen/CssToInlineStyles",
"time": "2016-09-20T12:50:39+00:00"
},
{
"name": "tivie/php-os-detector",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/tivie/php-os-detector.git",
"reference": "9461dcd85c00e03842264f2fc8ccdc8d46867321"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tivie/php-os-detector/zipball/9461dcd85c00e03842264f2fc8ccdc8d46867321",
"reference": "9461dcd85c00e03842264f2fc8ccdc8d46867321",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "4.3.*"
},
"type": "library",
"autoload": {
"psr-4": {
"Tivie\\OS\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"APACHE 2.0"
],
"authors": [
{
"name": "Estevão Soares dos Santos",
"email": "estevao@soares-dos-santos.com"
}
],
"description": "A small utility library that detects the OS the server is running on",
"homepage": "http://tivie.github.com/php-os-detector/",
"keywords": [
"detection",
"detector",
"identification",
"operating system",
"os",
"os detection"
],
"time": "2017-10-21T03:33:59+00:00"
},
{
"name": "toin0u/geotools-laravel",
"version": "1.0.0",
@ -6984,7 +7032,7 @@
},
{
"name": "symfony/class-loader",
"version": "v3.4.0",
"version": "v3.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/class-loader.git",
@ -7045,7 +7093,6 @@
"infyomlabs/laravel-generator": 20,
"infyomlabs/adminlte-templates": 20,
"zizaco/entrust": 20,
"league/geotools": 0,
"makinacorpus/php-bloom": 20,
"nabeel/laravel-installer": 20
},