Skip to content

Commit

Permalink
stream: better platform compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mmomtchev committed Nov 26, 2020
1 parent 0653acf commit 7fc79f0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/parallel/test-stdin-from-file-spawn.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
'use strict';
const common = require('../common');
const process = require('process');
if (process.platform !== 'linux' && process.platform !== 'darwin')
common.skip('This is an UNIX-only test');

let defaultShell;
if (process.platform === 'linux' || process.platform === 'darwin') {
defaultShell = '/bin/sh';
} else if (process.platform === 'win32') {
defaultShell = 'cmd.exe';
} else {
common.skip('This is test exists only on Linux/Win32/OSX');
}

const { execSync } = require('child_process');
const fs = require('fs');
Expand All @@ -21,7 +28,8 @@ const { spawn } = require('child_process');
process.stdin;
setTimeout(() => {
let ok = false;
const child = spawn(process.env.SHELL, [], { stdio: ['inherit', 'pipe'] });
const child = spawn(process.env.SHELL || '${defaultShell}',
[], { stdio: ['inherit', 'pipe'] });
child.stdout.on('data', () => {
ok = true;
});
Expand Down

0 comments on commit 7fc79f0

Please sign in to comment.