Skip to content

Several Windows fixes. #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,19 @@ public function setCommand($command)
}
if ($this->getIsWindows()) {
// Make sure to switch to correct drive like "E:" first if we have a full path in command
$chdrive = (isset($command[1]) && $command[1]===':') ? $command[0].': && ' : '';
$command = sprintf($chdrive.'cd %s && %s', escapeshellarg(dirname($command)), basename($command));
if (isset($command[1]) && $command[1]===':') {
$position = 1;
// Could be a quoted absolute path because of spaces. i.e. "C:\Program Files (x86)\file.exe"
} elseif (isset($command[2]) && $command[2]===':') {
$position = 2;
} else {
$position = false;
}

// Absolute path. If it's a relative path, let it slide.
if ($position) {
$command = sprintf($command[$position - 1].': && cd %s && %s', escapeshellarg(dirname($command)), basename($command));
}
}
$this->_command = $command;
return $this;
Expand Down