-
Notifications
You must be signed in to change notification settings - Fork 24
Description
The current implementation of the construction of the path for Sass binary relies on the expectation that the main entry point is always named sass:
sass-bundle/src/SassBinary.php
Lines 162 to 165 in aa47da8
| private function getDefaultBinaryPath(): string | |
| { | |
| return $this->binaryDownloadDir.'/dart-sass/sass'; | |
| } |
But this is not true for Windows, where it is a sass.bat. Effectively it results in a re-download of the Sass distributive for each build due to this logic:
sass-bundle/src/SassBinary.php
Lines 37 to 40 in aa47da8
| $binary = $this->getDefaultBinaryPath(); | |
| if (!is_file($binary)) { | |
| $this->downloadExecutable(); | |
| } |
Correct implementation of the getDefaultBinaryPath method would be:
private function getDefaultBinaryPath(): string
{
return $this->binaryDownloadDir.'/dart-sass/sass'.(str_contains(strtolower(\PHP_OS), 'win') ? '.bat' : '');
}There is also one more related and Windows-specific issue:
Normally after download bundle tests that download results in the appearance of the Sass binary and throws an exception if it is not so:
sass-bundle/src/SassBinary.php
Lines 109 to 112 in aa47da8
| $binaryPath = $this->getDefaultBinaryPath(); | |
| if (!is_file($binaryPath)) { | |
| throw new \Exception(sprintf('Could not find downloaded binary in "%s".', $binaryPath)); | |
| } |
However, for Windows, no such check is applied because there is a separate branch for archive extraction that ends with unconditional return.
sass-bundle/src/SassBinary.php
Lines 87 to 97 in aa47da8
| if ($isZip) { | |
| if (!\extension_loaded('zip')) { | |
| throw new \Exception('Cannot unzip the downloaded sass binary. Please install the "zip" PHP extension.'); | |
| } | |
| $archive = new \ZipArchive(); | |
| $archive->open($targetPath); | |
| $archive->extractTo($this->binaryDownloadDir); | |
| $archive->close(); | |
| unlink($targetPath); | |
| return; |
Because of this, in case if Sass binary download will not cause the Sass compiler to actually appear in the filesystem it will not be reported.