throw exception if java is not found
This commit is contained in:
parent
019092b77b
commit
0888283a76
1 changed files with 11 additions and 4 deletions
|
@ -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}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,7 +132,7 @@ class ClosureCompiler
|
||||||
* Add an entry to the list of source files
|
* Add an entry to the list of source files
|
||||||
*
|
*
|
||||||
* @param string $file
|
* @param string $file
|
||||||
*
|
*
|
||||||
* @return null
|
* @return null
|
||||||
* @throws CompilerException
|
* @throws CompilerException
|
||||||
*/
|
*/
|
||||||
|
@ -180,7 +187,7 @@ class ClosureCompiler
|
||||||
* Set the name of the resulting compiled javascript file
|
* Set the name of the resulting compiled javascript file
|
||||||
*
|
*
|
||||||
* @param string $file
|
* @param string $file
|
||||||
*
|
*
|
||||||
* @throws CompilerException
|
* @throws CompilerException
|
||||||
*/
|
*/
|
||||||
public function setTargetFile($file)
|
public function setTargetFile($file)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue