diff --git a/src/Commands/GenerateCollectionSchema.php b/src/Commands/GenerateCollectionSchema.php index bf8a845..9849fdc 100644 --- a/src/Commands/GenerateCollectionSchema.php +++ b/src/Commands/GenerateCollectionSchema.php @@ -27,6 +27,12 @@ class GenerateCollectionSchema extends Command $json = json_encode($schema, JSON_PRETTY_PRINT); $configDir = base_path(config('lucent.schemas_path')); + + if(!file_exists($configDir)) { + $this->error("Your config directory \"$configDir\" doesn't exist. Create it first and run again"); + return; + } + $schemaPath = $configDir . "/" . $name . '.json'; if(file_exists($schemaPath)){ diff --git a/src/Commands/GenerateFileSchema.php b/src/Commands/GenerateFileSchema.php index 56673af..d452ade 100644 --- a/src/Commands/GenerateFileSchema.php +++ b/src/Commands/GenerateFileSchema.php @@ -28,8 +28,15 @@ class GenerateFileSchema extends Command $json = json_encode($schema, JSON_PRETTY_PRINT); $configDir = base_path(config('lucent.schemas_path')); + + if(!file_exists($configDir)) { + $this->error("Your config directory \"$configDir\" doesn't exist. Create it first and run again"); + return; + } + $schemaPath = $configDir . "/" . $name . '.json'; + if (file_exists($schemaPath)) { $this->error("The schema file already exists."); return 0;