Skip to content
Closed
Changes from 2 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
13 changes: 9 additions & 4 deletions test/parallel/test-repl-require-after-write.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
'use strict';

const common = require('../common');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');

const spawn = require('child_process').spawn;

tmpdir.refresh();

const requirePath = tmpdir.path + '/non-existent.json';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: path.join()?


// Use -i to force node into interactive mode, despite stdout not being a TTY
const child = spawn(process.execPath, ['-i']);

let out = '';
const input = "try { require('./non-existent.json'); } catch {} " +
"require('fs').writeFileSync('./non-existent.json', '1');" +
"require('./non-existent.json');";
const input = `try { require('${requirePath}'); } catch {} ` +
`require('fs').writeFileSync('${requirePath}', '1');` +
`require('${requirePath}');`;

child.stderr.on('data', common.mustNotCall());

Expand Down