throw exception if java is not found

This commit is contained in:
Max Tsepkov 2013-08-14 16:44:23 +06:00
parent 019092b77b
commit 0888283a76

View file

@ -37,7 +37,7 @@ namespace Devize\ClosureCompiler;
*/ */
class ClosureCompiler class ClosureCompiler
{ {
protected $java;
protected $compilerJar = 'compiler-latest/compiler.jar'; protected $compilerJar = 'compiler-latest/compiler.jar';
protected $config = array( protected $config = array(
@ -62,7 +62,14 @@ class ClosureCompiler
*/ */
public function getBinary() public function getBinary()
{ {
return 'java -jar ' . $this->compilerJar; if (!$this->java) {
$this->java = rtrim(shell_exec('which java'));
if (!$this->java) {
throw new \RuntimeException('java could not be found in PATH.');
}
}
return "{$this->java} -jar {$this->compilerJar}";
} }
/** /**