Skip to content

Commit

Permalink
feat: Expose settings and host-config when executing scaffold from a …
Browse files Browse the repository at this point in the history
…script
  • Loading branch information
stmh committed May 7, 2024
1 parent 001d0e0 commit b58efb4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Scaffolder/Callbacks/ScaffoldCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function handle(TaskContextInterface $context, ...$arguments)
$scaffold_url = $base_path . substr($scaffold_url, 1);
}
$scaffold_root_folder = array_shift($arguments);
$tokens = Utilities::mergeData($context->get('tokens', []), $this->getTokens($arguments));
$tokens = Utilities::mergeData($context->get('tokens', []), $this->getTokens($context, $arguments));
$this->scaffold($context, $scaffold_url, $scaffold_root_folder, $tokens);
}

Expand Down Expand Up @@ -73,9 +73,14 @@ public function scaffold(
$scaffolder->scaffold($scaffold_url, dirname($scaffold_root_folder), $cloned_context, $tokens, $options);
}

private function getTokens(array $arguments):array
private function getTokens(TaskContextInterface $context, array $arguments):array
{
$result = [];
if ($config = $context->getConfigurationService()) {
$result['settings'] = $config->getAllSettings();
$shell = $context->getShell();
$result['host'] = $shell && $shell->getHostConfig() ? $shell->getHostConfig()->asArray() : [];
}
foreach ($arguments as $arg) {
if (strpos($arg, "=") === false) {
throw new \RuntimeException(sprintf("Can't parse argument %s", $arg));
Expand Down

0 comments on commit b58efb4

Please sign in to comment.