Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/node.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -140,6 +140,7 @@
}

} else{
startup.preloadModules();
// If -i or --interactive were passed, or stdin is a TTY.
if (process._forceRepl || NativeModule.require('tty').isatty(0)){
// REPL
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/define-global.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
global.a = 'test'
15 changes: 14 additions & 1 deletion test/parallel/test-preload.js
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
'use strict'
require('../common');
const common = require('../common');
const assert = require('assert');
const path = require('path');
const child_process = require('child_process');
Expand All@@ -21,6 +21,7 @@ var fixture = function(name){
var fixtureA = fixture('printA.js');
var fixtureB = fixture('printB.js');
var fixtureC = fixture('printC.js');
const fixtureD = fixture('define-global.js');
var fixtureThrows = fixture('throws_error4.js');

// test preloading a single module works
Expand DownExpand Up@@ -73,6 +74,18 @@ child_process.exec(nodeBinary + ' '
assert.equal(stdout, 'A\nB\nhello\n');
});

// test that preload works with -i
const interactive = child_process.exec(nodeBinary + ' '
+ preloadOption([fixtureD])
+ '-i',
common.mustCall(function(err, stdout, stderr){
assert.ifError(err);
assert.strictEqual(stdout, `> 'test'\n> `);
}));

interactive.stdin.write('a\n');
interactive.stdin.write('process.exit()\n');

child_process.exec(nodeBinary + ' '
+ '--require ' + fixture('cluster-preload.js') + ' '
+ fixture('cluster-preload-test.js'),
Expand Down