You are here

public function MinifyJsCommands::minifyJs in Minify JS 8

Same name and namespace in other branches
  1. 8.2 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 45

Class

MinifyJsCommands
A Drush commandfile.

Namespace

Drupal\minifyjs\Commands

Code

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

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