MXS-2368: Fix reading of non-tty input

The password input only worked if stdin was a TTY. This was caused by the
fact that the readline-sync library only worked for TTYs.
This commit is contained in:
Markus Mäkelä 2019-03-07 04:33:54 +02:00
parent 8a0b6005a4
commit 160b4e6e05
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -50,9 +50,14 @@ module.exports = function() {
// No password given, ask it from the command line
if (argv.p == '') {
argv.p = readlineSync.question('Enter password: ', {
hideEchoBack: true
})
if (process.stdin.isTTY) {
argv.p = readlineSync.question('Enter password: ', {
hideEchoBack: true
})
} else {
var line = fs.readFileSync(0)
argv.p = line.toString().trim()
}
}
// Split the hostnames, separated by commas