Skip to content

Commit

Permalink
Merge pull request #49 from bestit-dfuchs/feature/env-console-script-…
Browse files Browse the repository at this point in the history
…path

added console_script_path option to environment config
  • Loading branch information
thomasbit authored Jan 2, 2019
2 parents 65f7077 + 15f2c6e commit ec6fb27
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ magephp:
releases: 4
# Add php_executable in environment options to overwrite the global configuration above
php_executable: /usr/bin/env/path/to/php
# Add console_script_path in environment options to overwrite the default ./bin/console
console_script_path: ./bin/console
hosts:
- production_server1
pre-deploy:
Expand Down
22 changes: 22 additions & 0 deletions src/Shopware/AbstractTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,26 @@ protected function getPathToPhpExecutable()

return $phpExecutable;
}

/**
* Returns the console script path if configured, otherwise ./bin/console as default value.
*
* @return string The configured or default console script path.
*/
protected function getPathToConsoleScript()
{
$consoleScriptPath = './bin/console';

$environmentConsoleScriptPath = $this->runtime->getEnvOption('console_script_path');

if ($environmentConsoleScriptPath !== null) {
$consoleScriptPath = $environmentConsoleScriptPath;
}

if ($this->runtime->getReleaseId() !== null) {
$consoleScriptPath = str_replace('%release%', $this->runtime->getReleaseId(), $consoleScriptPath);
}

return $consoleScriptPath;
}
}
9 changes: 7 additions & 2 deletions src/Shopware/AbstractUpdatePluginsTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ protected function updateAllInDir($directory)
}

$cmd = sprintf(
'%s ./bin/console sw:plugin:update %s',
'%s %s sw:plugin:update %s',
$this->getPathToPhpExecutable(),
$this->getPathToConsoleScript(),
$file->getFilename()
);

Expand All @@ -78,7 +79,11 @@ protected function updateAllInDir($directory)
*/
protected function refreshPluginList()
{
$cmd = sprintf('%s ./bin/console sw:plugin:refresh', $this->getPathToPhpExecutable());
$cmd = sprintf(
'%s %s sw:plugin:refresh',
$this->getPathToPhpExecutable(),
$this->getPathToConsoleScript()
);
$process = $this->runtime->runRemoteCommand($cmd, true);

if (!$process->isSuccessful()) {
Expand Down
3 changes: 2 additions & 1 deletion src/Shopware/CommandTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ public function execute()
}

$cmd = sprintf(
'%s ./bin/console %s %s',
'%s %s %s %s',
$this->getPathToPhpExecutable(),
$this->getPathToConsoleScript(),
$this->getCommand(),
$this->options['flags']
);
Expand Down

0 comments on commit ec6fb27

Please sign in to comment.