mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-24 01:02:24 +01:00
Add remoteEnv() func
This commit is contained in:
parent
5cae26d442
commit
234c19d8d2
@ -841,3 +841,21 @@ function locateBinaryPath(string $name): string
|
||||
return trim(str_replace("$name is", "", $path));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns remote environments variables as an array.
|
||||
* ```php
|
||||
* $remotePath = remoteEnv()['PATH'];
|
||||
* run('echo $PATH', env: ['PATH' => "/home/user/bin:$remotePath"]);
|
||||
* ```
|
||||
*/
|
||||
function remoteEnv(): array
|
||||
{
|
||||
$vars = [];
|
||||
$data = run('env');
|
||||
foreach (explode("\n", $data) as $line) {
|
||||
list($name, $value) = explode('=', $line, 2);
|
||||
$vars[$name] = $value;
|
||||
}
|
||||
return $vars;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user