Skip to content

Commit 7fc79f0

Browse files
committed
stream: better platform compatibility
1 parent 0653acf commit 7fc79f0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/parallel/test-stdin-from-file-spawn.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
'use strict';
22
const common = require('../common');
33
const process = require('process');
4-
if (process.platform !== 'linux' && process.platform !== 'darwin')
5-
common.skip('This is an UNIX-only test');
4+
5+
let defaultShell;
6+
if (process.platform === 'linux' || process.platform === 'darwin') {
7+
defaultShell = '/bin/sh';
8+
} else if (process.platform === 'win32') {
9+
defaultShell = 'cmd.exe';
10+
} else {
11+
common.skip('This is test exists only on Linux/Win32/OSX');
12+
}
613

714
const { execSync } = require('child_process');
815
const fs = require('fs');
@@ -21,7 +28,8 @@ const { spawn } = require('child_process');
2128
process.stdin;
2229
setTimeout(() => {
2330
let ok = false;
24-
const child = spawn(process.env.SHELL, [], { stdio: ['inherit', 'pipe'] });
31+
const child = spawn(process.env.SHELL || '${defaultShell}',
32+
[], { stdio: ['inherit', 'pipe'] });
2533
child.stdout.on('data', () => {
2634
ok = true;
2735
});

0 commit comments

Comments
 (0)