code: public function combineJsFiles($inputFiles, $outputFile)
      {
          $content = '';
          foreach ($inputFiles as $file) {
              // Add a semicolon to source code if trailing semicolon missing.
              // Notice: It needs a new line before `;` to avoid affection of line comment. (// ...;)
              $fileContent = rtrim(file_get_contents($file));
              if (substr($fileContent, -1) !== ';') {
                  $fileContent .= "\n;";
              }
              $content .= "/*** BEGIN FILE: $file ***/\n"
                  . $fileContent . "\n"
                  . "/*** END FILE: $file ***/\n";
          }
          if (!file_put_contents($outputFile, $content)) {
              throw new Exception("Unable to write output JavaScript file '{$outputFile}'.");
          }
      }
docs: Combines JavaScript files into a single one.
  @param array $inputFiles source file names.
  @param string $outputFile output file name.
  @throws \yii\console\Exception on failure.