aboutsummaryrefslogtreecommitdiff
path: root/bin/uglifyjs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/uglifyjs')
-rwxr-xr-xbin/uglifyjs13
1 files changed, 8 insertions, 5 deletions
diff --git a/bin/uglifyjs b/bin/uglifyjs
index 9d2eedcb..88fd46bd 100755
--- a/bin/uglifyjs
+++ b/bin/uglifyjs
@@ -347,12 +347,15 @@ 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";
- }
try {
+ if (filename == "-") {
+ var chunks = [];
+ do {
+ var chunk = fs.readFileSync("/dev/stdin", "utf8");
+ chunks.push(chunk);
+ } while (chunk.length);
+ return chunks.join("");
+ }
return fs.readFileSync(filename, "utf8");
} catch(ex) {
sys.error("ERROR: can't read file: " + filename);