|
1 | 1 | 'use strict'; |
2 | 2 | const common = require('../common'); |
3 | 3 | 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'); |
9 | 5 |
|
10 | 6 | const entryPoints = ['iDoNotExist', 'iDoNotExist.js', 'iDoNotExist.mjs']; |
11 | 7 | const flags = [[], ['--experimental-modules']]; |
12 | 8 | const node = process.argv[0]; |
13 | 9 |
|
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; |
26 | 18 | } |
| 19 | + assert.fail('Executing node with inexistent entry point should fail. ' + |
| 20 | + `Entry point: ${entryPoint}, Flags: [${args}]`); |
27 | 21 | } |
28 | | -})(); |
| 22 | +} |
0 commit comments