Skip to content

Commit c98fe52

Browse files
committed
Move error throwing out to push command
1 parent 52970ff commit c98fe52

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "nandi95/laravel-env-in-aws-ssm",
3-
"version": "0.1.0",
4-
"description": "Manage your environment variables in in AWS' SSM Parameter store",
3+
"version": "0.1.1",
4+
"description": "Manage your environment variables in AWS' SSM Parameter store",
55
"type": "library",
66
"license": "MIT",
77
"autoload": {

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Console/EnvPush.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Exception;
66
use Illuminate\Console\Command;
7+
use InvalidArgumentException;
78
use Nandi95\LaravelEnvInAwsSsm\Traits\InteractsWithSSM;
89

910
class EnvPush extends Command
@@ -35,6 +36,10 @@ public function handle(): int
3536
{
3637
$this->stage = $this->argument('stage');
3738

39+
if (!file_exists('.env.' . $this->stage)) {
40+
throw new InvalidArgumentException("'.env.$this->stage' doesn't exists.");
41+
}
42+
3843
$localEnvs = $this->getEnvironmentVarsFromFile();
3944
$bar = $this->getOutput()->createProgressBar($localEnvs->count() + 1);
4045
$remoteEnvs = $this->getEnvironmentVarsFromRemote();

src/Traits/InteractsWithSSM.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ private function getEnvironmentVarsFromFile(): Collection
194194
{
195195
$path = '.env.' . $this->stage;
196196

197-
if (!file_exists($path)) {
198-
throw new InvalidArgumentException("'$path' doesn't exists.");
197+
if (file_exists($path)) {
198+
return collect($this->getDotenv()->parse(file_get_contents($path)));
199199
}
200200

201-
return collect($this->getDotenv()->parse(file_get_contents($path)));
201+
return collect();
202202
}
203203

204204
/**

0 commit comments

Comments
 (0)