Skip to content

Commit

Permalink
Allow external options
Browse files Browse the repository at this point in the history
  • Loading branch information
smnandre committed Dec 20, 2023
1 parent cbee176 commit 4159941
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/SassBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public function runBuild(bool $watch): Process

$args = [
...$this->getScssCssTargets(),
...$this->getBuildOptions(),
...($watch ? ['--watch'] : []),
...$this->getBuildOptions(['--watch' => $watch]),
];

$process = $binary->createProcess($args);
Expand Down Expand Up @@ -129,12 +128,14 @@ public static function guessCssNameFromSassFile(string $sassFile, string $output
}

/**
* @param array<string, bool|string> $options
*
* @return list<string>
*/
public function getBuildOptions(): array
public function getBuildOptions(array $options = []): array
{
$buildOptions = [];
$options = [...self::SASS_OPTIONS, ...$this->sassOptions];
$options = [...self::SASS_OPTIONS, ...$this->sassOptions, ...$options];
foreach ($options as $option => $value) {
// Set only the defined options.
if (null === $value) {
Expand All @@ -149,6 +150,12 @@ public function getBuildOptions(): array
// --style=compressed
if (\is_string($value)) {
$buildOptions[] = $option.'='.$value;
continue;
}
// --update
// --watch
if ($value) {
$buildOptions[] = $option;
}
}

Expand Down

0 comments on commit 4159941

Please sign in to comment.