Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
CHH opened this Issue · 3 comments

2 participants

@CHH

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
@davglass davglass was assigned
@davglass
Owner

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 davglass closed this in 3c101d3
@davglass
Owner

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

Awesome! Thanks :smile:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.