From 21984a475acfbb8ad086239cd671fbff55582398 Mon Sep 17 00:00:00 2001 From: Eric Van Johnson Date: Wed, 29 Apr 2020 15:16:46 -0700 Subject: [PATCH 1/2] Look for multiple versions of draft --- src/Commands/BlueprintCommand.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Commands/BlueprintCommand.php b/src/Commands/BlueprintCommand.php index 6a5b0e37..b2b861ab 100644 --- a/src/Commands/BlueprintCommand.php +++ b/src/Commands/BlueprintCommand.php @@ -16,7 +16,7 @@ class BlueprintCommand extends Command * * @var string */ - protected $signature = 'blueprint:build {draft=draft.yaml}'; + protected $signature = 'blueprint:build {draft?}'; /** * The console command description. @@ -46,7 +46,8 @@ public function __construct(Filesystem $files) */ public function handle() { - $file = $this->argument('draft'); + $file = $this->argument('draft') ?? $this->getDraft(); + if (!file_exists($file)) { $this->error('Draft file could not be found: ' . $file); } @@ -96,4 +97,14 @@ private function outputStyle($action) return 'info'; } + + private function getDraft() + { + if (file_exists('draft.yaml')) { + $draft = 'draft.yaml'; + } elseif (file_exists('draft.yml')) { + $draft = 'draft.yml'; + } + return $draft; + } } From e03297f889f426aa5870db3ecca4ca6ce5c21536 Mon Sep 17 00:00:00 2001 From: Jason McCreary Date: Wed, 29 Apr 2020 20:44:45 -0400 Subject: [PATCH 2/2] BaseCoding --- src/Commands/BlueprintCommand.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Commands/BlueprintCommand.php b/src/Commands/BlueprintCommand.php index b2b861ab..44e5e34a 100644 --- a/src/Commands/BlueprintCommand.php +++ b/src/Commands/BlueprintCommand.php @@ -46,7 +46,7 @@ public function __construct(Filesystem $files) */ public function handle() { - $file = $this->argument('draft') ?? $this->getDraft(); + $file = $this->argument('draft') ?? $this->defaultDraftFile(); if (!file_exists($file)) { $this->error('Draft file could not be found: ' . $file); @@ -98,13 +98,16 @@ private function outputStyle($action) return 'info'; } - private function getDraft() + private function defaultDraftFile() { if (file_exists('draft.yaml')) { - $draft = 'draft.yaml'; - } elseif (file_exists('draft.yml')) { - $draft = 'draft.yml'; + return 'draft.yaml'; + } + + if (file_exists('draft.yml')) { + return 'draft.yml'; } - return $draft; + + return null; } }