1'use strict'; 2 3const common = require('../common'); 4const assert = require('assert'); 5const { exec } = require('child_process'); 6const fixtures = require('../common/fixtures'); 7 8const node = process.execPath; 9 10// Test both sets of arguments that check syntax 11const syntaxArgs = [ 12 ['-c'], 13 ['--check'], 14]; 15 16// Test good syntax with and without shebang 17[ 18 'syntax/good_syntax.js', 19 'syntax/good_syntax', 20 'syntax/good_syntax.mjs', 21 'syntax/good_syntax_shebang.js', 22 'syntax/good_syntax_shebang', 23 'syntax/illegal_if_not_wrapped.js', 24].forEach(function(file) { 25 file = fixtures.path(file); 26 27 // Loop each possible option, `-c` or `--check` 28 syntaxArgs.forEach(function(args) { 29 const _args = args.concat(file); 30 31 const cmd = [node, ..._args].join(' '); 32 exec(cmd, common.mustCall((err, stdout, stderr) => { 33 if (err) { 34 console.log('-- stdout --'); 35 console.log(stdout); 36 console.log('-- stderr --'); 37 console.log(stderr); 38 } 39 assert.ifError(err); 40 assert.strictEqual(stdout, ''); 41 assert.strictEqual(stderr, ''); 42 })); 43 }); 44}); 45