test: fix test-repl-require-after-write · nodejs/node@58aaf58 (original) (raw)
1
1
`'use strict';
`
2
2
``
3
3
`const common = require('../common');
`
``
4
`+
const tmpdir = require('../common/tmpdir');
`
4
5
`const assert = require('assert');
`
5
``
-
6
6
`const spawn = require('child_process').spawn;
`
``
7
`+
const path = require('path');
`
``
8
+
``
9
`+
tmpdir.refresh();
`
``
10
+
``
11
`+
const requirePath = JSON.stringify(path.join(tmpdir.path, 'non-existent.json'));
`
``
12
+
7
13
`// Use -i to force node into interactive mode, despite stdout not being a TTY
`
8
14
`const child = spawn(process.execPath, ['-i']);
`
9
15
``
10
16
`let out = '';
`
11
``
`-
const input = "try { require('./non-existent.json'); } catch {} " +
`
12
``
`-
"require('fs').writeFileSync('./non-existent.json', '1');" +
`
13
``
`-
"require('./non-existent.json');";
`
``
17
`` +
const input = try { require(${requirePath}); } catch {}
+
``
``
18
`` +
require('fs').writeFileSync(${requirePath}, '1');
+
``
``
19
`` +
require(${requirePath});
;
``
14
20
``
15
21
`child.stderr.on('data', common.mustNotCall());
`
16
22
``