diff --git a/test/parallel/test-child-process-exec-enforce-shell.js b/test/parallel/test-child-process-exec-enforce-shell.js new file mode 100644 index 00000000000000..83c080037c0ae0 --- /dev/null +++ b/test/parallel/test-child-process-exec-enforce-shell.js @@ -0,0 +1,23 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const { exec, execSync } = require('child_process'); + +const invalidArgTypeError = { + code: 'ERR_INVALID_ARG_TYPE', + name: 'TypeError' +}; + +exec('echo should-be-passed-as-argument', { shell: '' }, common.mustSucceed((stdout, stderr) => { + assert.match(stdout, /should-be-passed-as-argument/); + assert.ok(!stderr); +})); + +{ + const ret = execSync('echo should-be-passed-as-argument', { encoding: 'utf-8', shell: '' }); + assert.match(ret, /should-be-passed-as-argument/); +} + +for (const fn of [exec, execSync]) { + assert.throws(() => fn('should-throw-on-boolean-shell-option', { shell: false }), invalidArgTypeError); +}