Skip to content

Commit

Permalink
Windows fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
schmittjoh committed Sep 16, 2011
1 parent 06d6816 commit cc2e9ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Assetic/Filter/CompassFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,13 @@ public function filterLoad(AssetInterface $asset)
unlink($configFile);
}

$output = $proc->getErrorOutput() ?: $proc->getOutput();
$output = str_replace("\r", '', $output);

throw new \RuntimeException(sprintf(
"An error occurred when running:\n%s\n\nOutput:\n%s",
$proc->getCommandLine(),
trim($proc->getErrorOutput() ?: $proc->getOutput())
$output
));
}

Expand Down
13 changes: 11 additions & 2 deletions src/Assetic/Util/ProcessBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
class ProcessBuilder
{
private static $isWindows;

private $arguments;
private $cwd;
private $env;
Expand All @@ -29,6 +31,10 @@ class ProcessBuilder
public function __construct(array $arguments = array())
{
$this->arguments = $arguments;

if (null === self::$isWindows) {
self::$isWindows = defined('PHP_WINDOWS_VERSION_MAJOR');
}
}

/**
Expand Down Expand Up @@ -97,16 +103,18 @@ public function getProcess()

$options = $this->options;

if (defined('PHP_WINDOWS_MAJOR_VERSION')) {
if (self::$isWindows) {
$options += array('bypass_shell' => true);

$args = $this->arguments;
$cmd = array_shift($args);

$script = '"'.$cmd.'"';
if ($args) {
$script .= ' '.implode(' ', array_map('escapeshellarg', $parts));
$script .= ' '.implode(' ', array_map('escapeshellarg', $args));
}

$script = 'cmd /V:ON /E:ON /C "'.$script.'"';
} else {
$script = implode(' ', array_map('escapeshellarg', $this->arguments));
}
Expand All @@ -115,3 +123,4 @@ public function getProcess()
return new Process($script, $this->cwd, $env, $this->stdin, $this->timeout, $options);
}
}

6 comments on commit cc2e9ad

@hades200082
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this in the release version yet? Causing me some real problems in my windows development environment

@FredoVelcro-zz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

Yes this is the same for me, please release !

@mlarcher
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this is still not implemented in the main branch :(

@danspam
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge these fixes. ProcessBuilder is totally broken on windows!

@mlarcher
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems those fixes have been merged at some point, but then Assetic began to depend on a development version of Symfony's Process.php without any tag/branch to find out where it forks.
Check http://stackoverflow.com/questions/9626777/how-to-have-assetic-sass-work-with-symfony2-in-windows for more infos on how to make it work in windows.

@schmittjoh
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are in the release version, and should also still be in Symfony.

Are you sure you don't have them?

Please sign in to comment.