Skip to content

Commit 1d9d6ed

Browse files
committed
squash: use assert.fail, execFileSync
1 parent 527c727 commit 1d9d6ed

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed
Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
11
'use strict';
22
const common = require('../common');
33
const assert = require('assert');
4-
const child_process = require('child_process');
5-
const { promisify } = require('util');
6-
const execFile = promisify(child_process.execFile);
7-
8-
common.crashOnUnhandledRejection();
4+
const { execFileSync } = require('child_process');
95

106
const entryPoints = ['iDoNotExist', 'iDoNotExist.js', 'iDoNotExist.mjs'];
117
const flags = [[], ['--experimental-modules']];
128
const node = process.argv[0];
139

14-
(async () => {
15-
for (const args of flags) {
16-
for (const entryPoint of entryPoints) {
17-
try {
18-
await execFile(node, args.concat(entryPoint));
19-
} catch (e) {
20-
assert.strictEqual(e.stdout, '');
21-
assert(e.stderr.match(/Error: Cannot find module/));
22-
continue;
23-
}
24-
throw new Error('Executing node with inexistent entry point should ' +
25-
`fail. Entry point: ${entryPoint}, Flags: [${args}]`);
10+
for (const args of flags) {
11+
for (const entryPoint of entryPoints) {
12+
try {
13+
execFileSync(node, args.concat(entryPoint), { stdio: 'pipe' });
14+
} catch (e) {
15+
assert.strictEqual(e.stdout.toString(), '');
16+
assert(e.stderr.toString().match(/Error: Cannot find module/));
17+
continue;
2618
}
19+
assert.fail('Executing node with inexistent entry point should fail. ' +
20+
`Entry point: ${entryPoint}, Flags: [${args}]`);
2721
}
28-
})();
22+
}

0 commit comments

Comments
 (0)