Skip to content

Commit

Permalink
Fixed symbold not actually written
Browse files Browse the repository at this point in the history
  • Loading branch information
mario-deluna committed Feb 19, 2024
1 parent 1195999 commit 15a32ee
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Command/SiliconGenDocSymbolsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ private function scanForMdFiles(string $path) : array
{
return glob($path . '/*.md') ?: [];
}


/**
* Converts the symbols to an array
*
* @param array<SiliconSymbol> $symbols
* @return array<mixed>
*/
private function convertSymbolsToArray(array $symbols) : array
{
$data = [];
Expand Down Expand Up @@ -150,7 +156,7 @@ public function execute()

// prcess the files
foreach($mdFiles as $mdFile) {
$this->cli->info("Processing file: {$mdFile}");
$this->info("Processing file: {$mdFile}");
$symbols = array_merge($symbols, $this->processFile($mdFile));
}

Expand All @@ -159,13 +165,20 @@ public function execute()
throw new SiliconDocGenException("The output path '{$outputPath}' is not writable.");
}

$this->cli->info("Writing symbols to: {$outputPath}");
$this->info("Writing symbols to: {$outputPath}");

// convert to json
$symbolData = $this->convertSymbolsToArray($symbols);
$json = json_encode($symbolData, JSON_PRETTY_PRINT);

$this->cli->json($symbolData);

// wrire to file
if (!file_put_contents($outputPath, $json)) {
throw new SiliconDocGenException("Could not write the symbols to: {$outputPath}");
}

$this->info("Symbols written to: {$outputPath}");
}

/**
Expand Down

0 comments on commit 15a32ee

Please sign in to comment.