Commit 5f1a01d 1 parent c6b993b commit 5f1a01d Copy full SHA for 5f1a01d
File tree 1 file changed +7
-10
lines changed
1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -258,28 +258,25 @@ if (common.hasCrypto) { // eslint-disable-line crypto-check
258
258
// Do our best to grab a tty fd.
259
259
function getTTYfd ( ) {
260
260
const tty = require ( 'tty' ) ;
261
- let tty_fd = 0 ;
262
- if ( ! tty . isatty ( tty_fd ) ) tty_fd ++ ;
263
- else if ( ! tty . isatty ( tty_fd ) ) tty_fd ++ ;
264
- else if ( ! tty . isatty ( tty_fd ) ) tty_fd ++ ;
265
- else {
261
+ let ttyFd = [ 0 , 1 , 2 ] . find ( tty . isatty ) ;
262
+ if ( ttyFd === undefined ) {
266
263
try {
267
- tty_fd = fs . openSync ( '/dev/tty' ) ;
264
+ ttyFd = fs . openSync ( '/dev/tty' ) ;
268
265
} catch ( e ) {
269
266
// There aren't any tty fd's available to use.
270
267
return - 1 ;
271
268
}
272
269
}
273
- return tty_fd ;
270
+ return ttyFd ;
274
271
}
275
272
276
- const tty_fd = getTTYfd ( ) ;
277
- if ( tty_fd >= 0 ) {
273
+ const ttyFd = getTTYfd ( ) ;
274
+ if ( ttyFd >= 0 ) {
278
275
const tty_wrap = process . binding ( 'tty_wrap' ) ;
279
276
// fd may still be invalid, so guard against it.
280
277
const handle = ( ( ) => {
281
278
try {
282
- return new tty_wrap . TTY ( tty_fd , false ) ;
279
+ return new tty_wrap . TTY ( ttyFd , false ) ;
283
280
} catch ( e ) {
284
281
return null ;
285
282
}
You can’t perform that action at this time.
0 commit comments