1'use strict'; 2 3require('../../common'); 4const { spawnSync } = require('child_process'); 5 6const four = require('../../common/fixtures') 7 .readSync('async-error.js') 8 .toString() 9 .split('\n') 10 .slice(2, -2) 11 .join('\n'); 12 13const main = `${four} 14 15async function main() { 16 try { 17 await four(); 18 } catch (e) { 19 console.log(e); 20 } 21} 22 23main(); 24`; 25 26// --eval ESM 27{ 28 const child = spawnSync(process.execPath, [ 29 '--input-type', 30 'module', 31 '-e', 32 main, 33 ], { 34 env: { ...process.env }, 35 }); 36 37 if (child.status !== 0) { 38 console.error(child.stderr.toString()); 39 } 40 console.error(child.stdout.toString()); 41} 42