Skip to content

Commit

Permalink
fix silent mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Gaal committed Aug 12, 2022
1 parent cebcaed commit 22939b4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions app/Commands/ExecuteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ExecuteCommand extends Command
{
protected $signature = 'execute {alias?} {parameters?*} {-s|--silent=false}';
protected $signature = 'execute {alias?} {parameters?*} {-s|--silent}';

protected $description = 'Executes an alias.';

Expand All @@ -23,15 +23,17 @@ public function handle()
try {
$this->getProjectAliases();

if ($alias && ! in_array($alias, array_keys($this->aliases))) {
if ($alias && !in_array($alias, array_keys($this->aliases))) {
$this->components->error("Alias $alias not found.");
}

if (! $alias) {
if (!$alias) {
$alias = $this->choice('Please select alias to execute', array_keys($this->aliases));
}

$this->components->info("Executing: $alias");
if (!$silent) {
$this->components->info("Executing: $alias");
}

if (is_array($this->aliases[$alias]) === false) {
$this->aliases[$alias] = [$this->aliases[$alias]];
Expand All @@ -46,15 +48,17 @@ public function handle()
);
}

if ($silent) {
@system($task);
} else {
$this->line(system($task));
$output = exec($task);

if (!$silent) {
$this->line($output);
}
}

$this->newLine();
$this->components->info('Finished.');
if (!$silent) {
$this->newLine();
$this->components->info('Finished.');
}
} catch (\Exception $exception) {
$this->components->error($exception->getMessage());
}
Expand All @@ -63,8 +67,8 @@ public function handle()
protected function getProjectAliases(): array
{
$file = match (true) {
File::exists($path = getcwd().'/aliases.dev.json') => File::get($path),
File::exists($path = getcwd().'/aliases.json') => File::get($path),
File::exists($path = getcwd() . '/aliases.dev.json') => File::get($path),
File::exists($path = getcwd() . '/aliases.json') => File::get($path),
default => throw new FileNotFoundException('aliases.json or aliases.dev.json not found.')
};

Expand Down
Binary file modified builds/alias
Binary file not shown.

0 comments on commit 22939b4

Please sign in to comment.