[Process] added optional argument for default executable
This commit is contained in:
parent
4bef9995c6
commit
5dc1a9bb58
@ -57,9 +57,9 @@ class Configuration implements ConfigurationInterface
|
|||||||
->booleanNode('use_controller')->defaultValue($this->debug)->end()
|
->booleanNode('use_controller')->defaultValue($this->debug)->end()
|
||||||
->scalarNode('read_from')->defaultValue('%kernel.root_dir%/../web')->end()
|
->scalarNode('read_from')->defaultValue('%kernel.root_dir%/../web')->end()
|
||||||
->scalarNode('write_to')->defaultValue('%assetic.read_from%')->end()
|
->scalarNode('write_to')->defaultValue('%assetic.read_from%')->end()
|
||||||
->scalarNode('java')->defaultValue(function() use ($finder) { $java = $finder->find('java'); return $java ? $java : '/usr/bin/java'; })->end()
|
->scalarNode('java')->defaultValue($finder->find('java', '/usr/bin/java'))->end()
|
||||||
->scalarNode('node')->defaultValue(function() use ($finder) { $node = $finder->find('node'); return $node ? $node : '/usr/bin/node'; })->end()
|
->scalarNode('node')->defaultValue($finder->find('node', '/usr/bin/node'))->end()
|
||||||
->scalarNode('sass')->defaultValue(function() use ($finder) { $saas = $finder->find('saas'); return $saas ? $saas : '/usr/bin/saas'; })->end()
|
->scalarNode('sass')->defaultValue($finder->find('sass', '/usr/bin/sass'))->end()
|
||||||
->end()
|
->end()
|
||||||
|
|
||||||
// bundles
|
// bundles
|
||||||
|
@ -34,11 +34,12 @@ class ExecutableFinder
|
|||||||
/**
|
/**
|
||||||
* Finds an executable by name.
|
* Finds an executable by name.
|
||||||
*
|
*
|
||||||
* @param string $name The executable name (without the extension)
|
* @param string $name The executable name (without the extension)
|
||||||
|
* @param string $default The default to return if no executable is found
|
||||||
*
|
*
|
||||||
* @return string|false The executable path or false if it cannot be found
|
* @return string The executable path or default value
|
||||||
*/
|
*/
|
||||||
public function find($name)
|
public function find($name, $default = null)
|
||||||
{
|
{
|
||||||
$dirs = explode(PATH_SEPARATOR, getenv('PATH') ? getenv('PATH') : getenv('Path'));
|
$dirs = explode(PATH_SEPARATOR, getenv('PATH') ? getenv('PATH') : getenv('Path'));
|
||||||
$suffixes = DIRECTORY_SEPARATOR == '\\' ? (getenv('PATHEXT') ? explode(PATH_SEPARATOR, getenv('PATHEXT')) : $this->suffixes) : array('');
|
$suffixes = DIRECTORY_SEPARATOR == '\\' ? (getenv('PATHEXT') ? explode(PATH_SEPARATOR, getenv('PATHEXT')) : $this->suffixes) : array('');
|
||||||
@ -50,6 +51,6 @@ class ExecutableFinder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return $default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user