Exemple #1
0
/**
 * Run command on server.
 *
 * @param string $command
 * @return Result
 */
function run($command)
{
    $server = Context::get()->getServer();
    $command = env()->parse($command);
    $workingPath = workingPath();
    if (!empty($workingPath)) {
        $command = "cd {$workingPath} && {$command}";
    }
    if (isVeryVerbose()) {
        writeln("<comment>Run</comment>: {$command}");
    }
    $output = $server->run($command);
    if (isDebug() && !empty($output)) {
        writeln(array_map(function ($line) {
            return "<fg=red>></fg=red> {$line}";
        }, explode("\n", $output)));
    }
    return new Result($output);
}
/**
 * Run command on server.
 *
 * @param string $command
 * @return Result
 */
function run($command)
{
    $server = Context::get()->getServer();
    $command = env()->parse($command);
    $workingPath = workingPath();
    if (!empty($workingPath)) {
        $command = "cd {$workingPath} && {$command}";
    }
    if (isVeryVerbose()) {
        writeln("<fg=red>></fg=red> {$command}");
    }
    $output = $server->run($command);
    if (isDebug() && !empty($output)) {
        output()->writeln(array_map(function ($line) {
            return "< {$line}";
        }, explode("\n", $output)), OutputInterface::OUTPUT_RAW);
    }
    return new Result($output);
}