Browse Source

Allow script to be read from stdin

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
4a9f2de956
  1. 21
      src/node.js

21
src/node.js

@ -80,9 +80,28 @@
console.log(rv);
} else {
// REPL
var binding = process.binding('stdio');
var fd = binding.openStdin();
var Module = NativeModule.require('module');
if (NativeModule.require('tty').isatty(fd)) {
// REPL
Module.requireRepl().start();
} else {
// Read all of stdin - execute it.
process.stdin.resume();
process.stdin.setEncoding('utf8');
var code = '';
process.stdin.on('data', function(d) {
code += d;
});
process.stdin.on('end', function() {
new Module()._compile(code, '[stdin]');
});
}
}
}

Loading…
Cancel
Save