cleanup makefile a bit

This commit is contained in:
Nabeel Shahzad 2017-12-06 17:31:20 -06:00
parent f0309e65de
commit a2bd4ff180
2 changed files with 27 additions and 18 deletions

View File

@ -11,17 +11,26 @@ all: build
.PHONY: build
build:
@composer install --no-interaction
@php artisan config:cache
@php artisan route:clear
@php artisan config:clear
@composer dump-autoload
.PHONY: db
db:
@php artisan database:create --reset
@php artisan database:create
@php artisan migrate:refresh --seed
.PHONY: install
install: build db
@echo "Done!"
.PHONY: update
update: db
@php artisan route:clear
@php artisan config:clear
@echo "Done!"
.PHONY: clean
clean:
@find bootstrap/cache -type f -not -name '.gitignore' -print0 | xargs -0 rm --
@ -31,12 +40,12 @@ clean:
@find storage/framework/sessions -type f -not -name '.gitignore' -print0 | xargs -0 rm --
@find storage/framework/views -type f -not -name '.gitignore' -print0 | xargs -0 rm --
@find storage/logs -type f -not -name '.gitignore' -print0 | xargs -0 rm --
@composer dump-autoload
@php artisan route:clear
@php artisan config:clear
.PHONY: reset
reset: clean
@php artisan database:create --reset
@make install
.PHONY: unittest-db

View File

@ -42,7 +42,7 @@ class CreateDatabase extends Command
protected function create_mysql($dbkey)
{
$exec = 'mysql';
if($this->os->isWindowsLike()) {
if ($this->os->isWindowsLike()) {
$exec .= '.exe';
}
@ -55,14 +55,14 @@ class CreateDatabase extends Command
# only supply password if it's set
$password = config($dbkey . 'password');
if($password !== '') {
if ($password !== '') {
$mysql_cmd[] = '-p' . $password;
}
if ($this->option('reset')) {
$cmd = array_merge(
$mysql_cmd,
["-e 'DROP DATABASE ".config($dbkey . 'database')."'"]
["-e 'DROP DATABASE " . config($dbkey . 'database') . "'"]
);
$this->runCommand($cmd);
@ -92,13 +92,15 @@ class CreateDatabase extends Command
$this->runCommand($cmd);
}
$cmd = [
$exec,
config($dbkey . 'database'),
'""',
];
if (!file_exists(config($dbkey . 'database'))) {
$cmd = [
$exec,
config($dbkey . 'database'),
'""',
];
$this->runCommand($cmd);
$this->runCommand($cmd);
}
}
/**
@ -114,16 +116,14 @@ class CreateDatabase extends Command
}
}*/
$this->info('Using connection "'.config('database.default').'"');
$this->info('Using connection "' . config('database.default') . '"');
$conn = config('database.default');
$dbkey = 'database.connections.'.$conn.'.';
$dbkey = 'database.connections.' . $conn . '.';
if(config($dbkey.'driver') === 'mysql') {
if (config($dbkey . 'driver') === 'mysql') {
$this->create_mysql($dbkey);
}
elseif (config($dbkey . 'driver') === 'sqlite') {
} elseif (config($dbkey . 'driver') === 'sqlite') {
$this->create_sqlite($dbkey);
}
}