Skip to content

Commit 578c0a0

Browse files
committed
did make extending environment $PATH for successful execution specific commands like as: mysql, mysqldump, and similar...
1 parent ae6a8cb commit 578c0a0

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

DeployApplication.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ private function exec(array $commands)
165165
if (is_array($command)) {
166166
$this->exec($command);
167167
} else {
168-
if ($key === 'php') {
169-
$command = $this->php() . ' ' . $command;
168+
if (is_string($key)) {
169+
$this->extendEnvironmentPath($key);
170+
$command = $key . ' ' . $command;
170171
}
171172
$this->logDated('$ ' . $command);
172173
exec($command . ' 2>&1', $response, $error_code);
@@ -179,6 +180,26 @@ private function exec(array $commands)
179180
}
180181
}
181182

183+
private function extendEnvironmentPath($command)
184+
{
185+
$extPath = '';
186+
if ($command === 'php') {
187+
$extPath = ':' . dirname($this->php());
188+
} else {
189+
exec('dirname $(whereis ' . $command . ') 2>&1', $response, $error_code);
190+
if (is_array($response)) {
191+
foreach (array_unique($response) as $path) {
192+
if ($path !== '.') {
193+
$extPath .= ':' . $path;
194+
}
195+
}
196+
}
197+
}
198+
if (!empty($extPath)) {
199+
putenv('PATH=' . getenv('PATH') . $extPath);
200+
}
201+
}
202+
182203
private function logDated($message)
183204
{
184205
if ($this->isFirstLogging) {

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "optimistex/git-auto-deploy-ex",
3-
"version": "1.3.2",
3+
"version": "1.3.3",
44
"type": "library",
55
"description": "The little project for auto-deploying projects to a hosting",
66
"keywords": [

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "git-auto-deploy-ex",
3-
"version": "1.3.2",
3+
"version": "1.3.3",
44
"description": "The little project for auto-deploying projects to a hosting",
55
"main": "index.js",
66
"directories": {

0 commit comments

Comments
 (0)