Skip to content
Permalink
Browse files

Refactor LauncherSsh (#163)

  • Loading branch information...
harold20 authored and enzolutions committed May 17, 2019
1 parent 9c73903 commit 214d430c59d67c887072682b02ddde7d713af84e
Showing with 17 additions and 12 deletions.
  1. +17 −12 src/Utils/LauncherSsh.php
@@ -7,6 +7,8 @@
namespace Drupal\Console\Launcher\Utils;
use Symfony\Component\Process\Process;
/**
* Class LauncherRemote
*
@@ -24,27 +26,30 @@ class LauncherSsh extends Launcher
*/
public function launch($options)
{
$drupalConsoleBinary = isset($options['options'])?isset($options['options']['drupal-console-binary'])?$options['options']['drupal-console-binary']:'drupal':'drupal';
$command = sprintf(
'%s/vendor/drupal/console/bin/drupal --root=%s %s',
$options['root'],
'%s --root=%s %s',
$drupalConsoleBinary,
$options['root'],
$this->parseArguments()
);
$command = $this->getSshConnectionString($options) . ' ' . $command;
$process = proc_open(
$command,
[0 => STDIN, 1 => STDOUT, 2 => STDERR],
$pipes
);
try {
$process = new Process($command);
$process->enableOutput();
$process->setTimeout(null);
$process->mustRun();
echo $process->getOutput();
// If process was successful, we'll return it's exit code to propagate
if ($process) {
return proc_close($process);
} catch (\Exception $e) {
echo $e->getMessage();
return 0;
}
return false;
return 1;
}
/**
@@ -59,7 +64,7 @@ private function getSshConnectionString($options)
}
$ssh = sprintf(
'ssh -A -tt %s%s%s%s',
'ssh -A %s%s%s%s',
$options['user'] ? : '',
$options['user'] ? '@' . $options['host'] : $options['host'],
$options['port'] ? ' -p ' . $options['port'] : '22',

0 comments on commit 214d430

Please sign in to comment.
You can’t perform that action at this time.