File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -249,28 +249,25 @@ if (common.hasCrypto) { // eslint-disable-line crypto-check
249249 // Do our best to grab a tty fd.
250250 function getTTYfd ( ) {
251251 const tty = require ( 'tty' ) ;
252- let tty_fd = 0 ;
253- if ( ! tty . isatty ( tty_fd ) ) tty_fd ++ ;
254- else if ( ! tty . isatty ( tty_fd ) ) tty_fd ++ ;
255- else if ( ! tty . isatty ( tty_fd ) ) tty_fd ++ ;
256- else {
252+ let ttyFd = [ 0 , 1 , 2 ] . find ( tty . isatty ) ;
253+ if ( ttyFd === undefined ) {
257254 try {
258- tty_fd = fs . openSync ( '/dev/tty' ) ;
255+ ttyFd = fs . openSync ( '/dev/tty' ) ;
259256 } catch ( e ) {
260257 // There aren't any tty fd's available to use.
261258 return - 1 ;
262259 }
263260 }
264- return tty_fd ;
261+ return ttyFd ;
265262 }
266263
267- const tty_fd = getTTYfd ( ) ;
268- if ( tty_fd >= 0 ) {
264+ const ttyFd = getTTYfd ( ) ;
265+ if ( ttyFd >= 0 ) {
269266 const tty_wrap = process . binding ( 'tty_wrap' ) ;
270267 // fd may still be invalid, so guard against it.
271268 const handle = ( ( ) => {
272269 try {
273- return new tty_wrap . TTY ( tty_fd , false ) ;
270+ return new tty_wrap . TTY ( ttyFd , false ) ;
274271 } catch ( e ) {
275272 return null ;
276273 }
You can’t perform that action at this time.
0 commit comments