mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-24 18:51:27 +08:00
Add possibility to customize path to binary using alias.
If you don't want to install command-line utils globally, you have to specify it's paths.
public $commands = [
'styl' => ['css', '@app/node_modules/bin/stylus < {from} > {to}'],
];
close #5130
This commit is contained in:
committed by
Carsten Brandt
parent
65edc03b49
commit
3d55ee5af0
@@ -25,6 +25,14 @@ class AssetConverter extends Component implements AssetConverterInterface
|
||||
* @var array the commands that are used to perform the asset conversion.
|
||||
* The keys are the asset file extension names, and the values are the corresponding
|
||||
* target script types (either "css" or "js") and the commands used for the conversion.
|
||||
*
|
||||
* You may also use a path alias to specify the location of the command:
|
||||
*
|
||||
* ```php
|
||||
* [
|
||||
* 'styl' => ['css', '@app/node_modules/bin/stylus < {from} > {to}'],
|
||||
* ]
|
||||
* ```
|
||||
*/
|
||||
public $commands = [
|
||||
'less' => ['css', 'lessc {from} {to} --no-color --source-map'],
|
||||
@@ -63,7 +71,7 @@ class AssetConverter extends Component implements AssetConverterInterface
|
||||
|
||||
/**
|
||||
* Runs a command to convert asset files.
|
||||
* @param string $command the command to run
|
||||
* @param string $command the command to run. If prefixed with an `@` it will be treated as a path alias.
|
||||
* @param string $basePath asset base path and command working directory
|
||||
* @param string $asset the name of the asset file
|
||||
* @param string $result the name of the file to be generated by the converter command
|
||||
@@ -73,6 +81,8 @@ class AssetConverter extends Component implements AssetConverterInterface
|
||||
*/
|
||||
protected function runCommand($command, $basePath, $asset, $result)
|
||||
{
|
||||
$command = Yii::getAlias($command);
|
||||
|
||||
$command = strtr($command, [
|
||||
'{from}' => escapeshellarg("$basePath/$asset"),
|
||||
'{to}' => escapeshellarg("$basePath/$result"),
|
||||
|
||||
Reference in New Issue
Block a user