Permalink
Browse files

add stdin/pipe support ; fix #15

thanks to @barbazul and Mathias Bynens http://stackoverflow.com/a/15485424
  • Loading branch information...
Franck Marcia
Franck Marcia committed Jan 28, 2014
1 parent 90fa06a commit d8fd51ee0c37e9022191754dae7b709d2e8feef5
Showing with 10 additions and 11 deletions.
  1. +10 −11 uglifycss
View
@@ -29,6 +29,7 @@
var util = require('util'),
uglifycss = require('./'),
uglies = [],
+ stdin = process.stdin,
filename,
content,
params,
@@ -108,21 +109,19 @@ if (nFiles) {
util.print(uglifycss.processFiles(params.files, params.options));
// . usage
-} else {
+} else if (stdin.isTTY) {
usage();
-}
-/*
// . stdin
} else {
- stdin = process.openStdin();
- stdin.setEncoding("utf8");
- content = '';
- stdin.on('data', function(part) {
- content += part;
+
+ content = '';
+
+ stdin.on('data', function (part) {
+ content += part;
});
- stdin.on('end', function() {
- util.print(uglifycss.processString(content, params.options));
+
+ stdin.on('end', function () {
+ util.print(uglifycss.processString(content, params.options));
});
}
-*/

0 comments on commit d8fd51e

Please sign in to comment.