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

Allow reading code from STDIN, and output on STDOUT #1

Closed
CHH opened this issue Oct 17, 2012 · 3 comments
Closed

Allow reading code from STDIN, and output on STDOUT #1

CHH opened this issue Oct 17, 2012 · 3 comments
Assignees

Comments

@CHH
Copy link

CHH commented Oct 17, 2012

I'm the author of an asset pipeline for PHP (http://github.com/CHH/pipe). For tool support it would be nice if yuglify would support piping JS/CSS into STDIN, and then outputting the minified code to STDOUT — just like the underlying uglifyjs.

An asset pipeline, has a filter pipeline where the output from the last filter gets put into the next filter. When using yuglifyjs in it's current state in a such filter pipeline, the tool needs to write the input data to a temporary file, and read the output back from another temporary file, which is cumbersome to use.

Switching between CSS and JS compression could be done via a flag, for example --css and --js.

Example:

% echo "foo" | yuglify --js
% echo "foo" | yuglify --css
@ghost ghost assigned davglass Oct 17, 2012
@davglass
Copy link
Member

I wasn't planning on adding a "nice" cli option for this since it was primarily used as a node dependency, but I'll look into this today and get at least this added..

@davglass
Copy link
Member

I added a --terminal flag to tell it when to read from stdin (personal preference, I hate assumptions).

So this now works:

cat foo.js | yuglify --type js --terminal //Prints to stdout
cat foo.css | yuglify --type css --terminal //Prints to stdout

cat foo.js | yuglify --type js --terminal --output ./foo-min.js
cat foo.css | yuglify --type css --terminal --output ./foo-min.css

@CHH
Copy link
Author

CHH commented Oct 17, 2012

Awesome! Thanks 😄

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

No branches or pull requests

2 participants