Skip to content

Commit

Permalink
fix(ci): unable to regenerate stat file even -w option is passed to…
Browse files Browse the repository at this point in the history
… the `stat` command

Signed-off-by: Fery Wardiyanto <[email protected]>
  • Loading branch information
feryardiant committed Jan 28, 2025
1 parent 34d9965 commit fddc68f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions workbench/app/Console/CommandHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ trait CommandHelpers

private function libPath(string ...$paths): Stringable
{
$path = \dirname(__DIR__).'/../..';
$path = realpath(\dirname(__DIR__).'/../..');

if (! empty($paths)) {
$path .= '/'.implode(DIRECTORY_SEPARATOR, $paths);
$path .= DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $paths);
}

return str(\realpath($path) ?: null);
return str($path);
}

private function group(string $title): void
Expand Down
6 changes: 3 additions & 3 deletions workbench/app/Console/StatCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function handle(Province $province): void
$diff = $this->option('diff') ?: false;
$diffs = $diff ? $this->getDiffs($rows) : [];

if (! empty($diffs) && $this->option('write')) {
if ($this->option('write')) {
File::put($this->libPath('tests/stats.json'), \json_encode($rows, \JSON_PRETTY_PRINT));
}

Expand Down Expand Up @@ -81,7 +81,7 @@ private function calculate(array $rows, array $diffs = []): array
return $out;
}

private function getDiffs(array $rows): ?array
private function getDiffs(array $rows): array
{
try {
$diffs = \array_filter(
Expand All @@ -93,7 +93,7 @@ private function getDiffs(array $rows): ?array
} catch (FileNotFoundException $err) {
$this->warn($err->getMessage());

return null;
return [];
}
}

Expand Down

0 comments on commit fddc68f

Please sign in to comment.