Skip to content

Commit 2288c07

Browse files
committed
add test cases for options.shell
1 parent e1377cc commit 2288c07

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const { exec, execSync } = require('child_process');
5+
6+
const invalidArgTypeError = {
7+
code: 'ERR_INVALID_ARG_TYPE',
8+
name: 'TypeError'
9+
};
10+
11+
exec('echo should-be-passed-as-argument', { shell: '' }, common.mustSucceed((stdout, stderr) => {
12+
assert.match(stdout, /should-be-passed-as-argument/);
13+
assert.ok(!stderr);
14+
}));
15+
16+
{
17+
const ret = execSync('echo should-be-passed-as-argument', { encoding: 'utf-8', shell: '' });
18+
assert.match(ret, /should-be-passed-as-argument/);
19+
}
20+
21+
for (const fn of [exec, execSync]) {
22+
assert.throws(() => fn('should-throw-on-boolean-shell-option', { shell: false }), invalidArgTypeError);
23+
}

0 commit comments

Comments
 (0)