Skip to content
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

Add filter for c version of jsmin #707

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add filter for c version of jsmin #707

wants to merge 1 commit into from

Conversation

felixyeung
Copy link

This is faster than the php JSMin implementation.

2 => array('pipe', 'w')
);

$process = proc_open($this->jsminBin, $descriptorspec, $pipes);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use the Process component rather than using proc_open directly (which is very tricky to make work cross-platform because it has lots of quirks)

@felixyeung
Copy link
Author

Updated the filter to use the Process component and read from getContent().

I was having issues getting this to work with Process::setStdin so I used shell redirection. This also works using a newer version of Process with setInput. Not sure what was changed in Process to fix this.

$tmpAssetFile = tempnam(sys_get_temp_dir(), 'assetic_cjsmin_');
file_put_contents($tmpAssetFile, $asset->getContent());

$process = new Process($this->jsminBin . ' < ' . $tmpAssetFile);
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this work on Windows too ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants