2017-05-14 22:57:54 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
|
2023-09-28 12:51:44 +00:00
|
|
|
if (common.isWindows || common.isAIX || common.isIBMi)
|
2017-05-14 22:57:54 +00:00
|
|
|
common.skip(`No /dev/stdin on ${process.platform}.`);
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
const { spawnSync } = require('child_process');
|
|
|
|
|
|
|
|
for (const code of [
|
|
|
|
`require('fs').realpath('/dev/stdin', (err, resolvedPath) => {
|
|
|
|
if (err) {
|
2021-01-18 15:26:13 +00:00
|
|
|
console.error(err);
|
2017-05-14 22:57:54 +00:00
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
if (resolvedPath) {
|
|
|
|
process.exit(2);
|
|
|
|
}
|
|
|
|
});`,
|
|
|
|
`try {
|
|
|
|
if (require('fs').realpathSync('/dev/stdin')) {
|
|
|
|
process.exit(2);
|
|
|
|
}
|
2021-01-18 15:26:13 +00:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
2017-05-14 22:57:54 +00:00
|
|
|
process.exit(1);
|
2021-03-26 15:51:08 +00:00
|
|
|
}`,
|
2017-05-14 22:57:54 +00:00
|
|
|
]) {
|
2021-01-18 15:26:13 +00:00
|
|
|
const child = spawnSync(process.execPath, ['-e', code], {
|
2017-05-14 22:57:54 +00:00
|
|
|
stdio: 'pipe'
|
2021-01-18 15:26:13 +00:00
|
|
|
});
|
|
|
|
if (child.status !== 2) {
|
|
|
|
console.log(code);
|
|
|
|
console.log(child.stderr.toString());
|
|
|
|
}
|
|
|
|
assert.strictEqual(child.status, 2);
|
2017-05-14 22:57:54 +00:00
|
|
|
}
|