Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
REPL sources file from NODE_STARTUP env var
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronj1335 committed Sep 12, 2011
1 parent 7e7e983 commit aac65ed
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/node.js
Expand Up @@ -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.
Expand Down

0 comments on commit aac65ed

Please sign in to comment.