You are here

public static function LibsassCompiler::getVersion in SCSS/Less Compiler 8

Returns compiler version.

Return value

string|bool Compiler version or FALSE if version not defined.

Overrides ScssCompilerPluginInterface::getVersion

File

src/Plugin/ScssCompiler/LibsassCompiler.php, line 83

Class

LibsassCompiler
Plugin implementation of the Libsass compiler.

Namespace

Drupal\scss_compiler\Plugin\ScssCompiler

Code

public static function getVersion() {

  // Parse package.json and find libsass version, because of run node-sass -v
  // take around 150ms.
  $node_modules_path = \Drupal::service('scss_compiler')
    ->getOption('node_modules_path');
  if (file_exists($node_modules_path . '/node-sass/package.json')) {
    $package = file_get_contents($node_modules_path . '/node-sass/package.json');
    $match = [];
    preg_match('/"libsass":\\s"([\\d\\.]+)"/', $package, $match);
    if (!empty($match[1])) {
      return $match[1];
    }
  }
  return FALSE;
}