test: fix test-tty-get-color-depth

If getTTYfd returns 0, and stdin is not writable (like on Windows),
trying to create WriteStream will fail. This commit fixes that by
skipping fd 0.

PR-URL: https://github.com/nodejs/node/pull/18478
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Bartosz Sosnowski 2018-01-31 16:48:21 +01:00 committed by Ruben Bridgewater
parent 0c16b18043
commit ef2861961c
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -10,7 +10,7 @@ const { WriteStream } = require('tty');
// Do our best to grab a tty fd.
function getTTYfd() {
const ttyFd = [0, 1, 2, 4, 5].find(tty.isatty);
const ttyFd = [1, 2, 4, 5].find(tty.isatty);
if (ttyFd === undefined) {
try {
return openSync('/dev/tty');