Merge pull request #146 from mbostock/read-all-stdin
Read the entire STDIN.
This commit is contained in:
commit
3bd7ca9961
13
bin/uglifyjs
13
bin/uglifyjs
|
|
@ -347,12 +347,15 @@ function getOptions(x, constants) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function read_whole_file(filename) {
|
function read_whole_file(filename) {
|
||||||
if (filename == "-") {
|
|
||||||
// XXX: this sucks. How does one read the whole STDIN
|
|
||||||
// synchronously?
|
|
||||||
filename = "/dev/stdin";
|
|
||||||
}
|
|
||||||
try {
|
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");
|
return fs.readFileSync(filename, "utf8");
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
sys.error("ERROR: can't read file: " + filename);
|
sys.error("ERROR: can't read file: " + filename);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user