Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

REPL sources file from NODE_STARTUP env var

  • Loading branch information...
commit aac65eda66e1c309656cbe0b434ba4bfd2c28683 1 parent 7e7e983
Aaron Stacy aaronj1335 authored
Showing with 19 additions and 1 deletion.
  1. +19 −1 src/node.js
20 src/node.js
View
@@ -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.
Please sign in to comment.
Something went wrong with that request. Please try again.