Browse files

REPL sources file from NODE_STARTUP env var

  • Loading branch information...
1 parent 7e7e983 commit aac65eda66e1c309656cbe0b434ba4bfd2c28683 @aaronj1335 aaronj1335 committed Sep 12, 2011
Showing with 19 additions and 1 deletion.
  1. +19 −1 src/node.js
View
20 src/node.js
@@ -107,8 +107,26 @@
var Module = NativeModule.require('module');
if (NativeModule.require('tty').isatty(fd)) {
+
// REPL
- Module.requireRepl().start();
+ var ctx = Module.requireRepl().start().context;
+
+ var startup = process.env.NODE_STARTUP;
+ if (startup) {
+ var path = NativeModule.require('path');
+ var fs = NativeModule.require('fs');
+ var vm = NativeModule.require('vm');
+
+ path.exists(startup, function(exists) {
+ if (exists) {
+ fs.readFile(startup, function(err, data) {
+ if (! err) {
+ vm.runInContext(data.toString('utf8'), ctx);
+ }
+ });
+ }
+ });
+ }
} else {
// Read all of stdin - execute it.

0 comments on commit aac65ed

Please sign in to comment.