From: Visa Kopu Date: Thu, 29 Nov 2012 08:51:15 +0000 (+0200) Subject: Fixed reading from STDIN. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=e48802ad291fae5a16f2d23cbd25a0c433cdbe48;p=UglifyJS.git Fixed reading from STDIN. --- diff --git a/bin/uglifyjs b/bin/uglifyjs index 1706629c..d2fbdb18 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -335,9 +335,8 @@ function getOptions(x, constants) { function read_whole_file(filename) { if (filename == "-") { - // XXX: this sucks. How does one read the whole STDIN - // synchronously? - filename = "/dev/stdin"; + var size = fs.fstatSync(process.stdin.fd).size; + return size > 0 ? fs.readSync(process.stdin.fd, size)[0] : ""; } try { return fs.readFileSync(filename, "utf8");