You are here

public function MinifyJsCommands::minifyJs in Minify JS 8.2

Same name and namespace in other branches
  1. 8 src/Commands/MinifyJsCommands.php \Drupal\minifyjs\Commands\MinifyJsCommands::minifyJs()

All js files minification.

@usage drush minify-js Js files minification.

@command minify-js @aliases minifyjs

File

src/Commands/MinifyJsCommands.php, line 58

Class

MinifyJsCommands
A Drush commandfile.

Namespace

Drupal\minifyjs\Commands

Code

public function minifyJs() {
  $this
    ->output()
    ->writeln('Minifying all JS files...');
  $files = $this->minifyJs
    ->loadAllFiles();
  foreach ($files as $fid => $file) {
    $status = $this->minifyJs
      ->minifyFile($fid);

    // Only output error messages.
    if ($status !== TRUE) {
      $this
        ->output()
        ->writeln($status);
    }
  }
  $this->cache
    ->delete(MINIFYJS_CACHE_CID);
  $this
    ->output()
    ->writeln('Complete!');
}