Check that mask is ''
This commit is contained in:
parent
95d2e9f088
commit
a7bb63d3e3
3 changed files with 8 additions and 5 deletions
|
@ -116,7 +116,7 @@ readlineSync.setPrint(function(display, encoding) {
|
||||||
currentMask = readlineSync.setMask([newMask])
|
currentMask = readlineSync.setMask([newMask])
|
||||||
```
|
```
|
||||||
|
|
||||||
Set the mask character that is shown instead of the secret text (e.g. password). (See `noEchoBack` option.) The default is `'*'`. If you want to show nothing, specify `''`. (But it's not user friendly.)
|
Set the mask character that is shown instead of the secret text (e.g. password). (See `noEchoBack` option.) The default is `'*'`. If you want to show nothing, specify `''`. (But it might be not user friendly in some cases.)
|
||||||
*Note:* The some platforms might use `'*'` or `''` always.
|
*Note:* The some platforms might use `'*'` or `''` always.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
|
@ -64,11 +64,12 @@ function getFso() {
|
||||||
|
|
||||||
function readS() {
|
function readS() {
|
||||||
var pw;
|
var pw;
|
||||||
|
// Microsoft Windows PowerShell https://technet.microsoft.com/ja-jp/library/hh847837.aspx
|
||||||
shellExec('powershell /?', function(exitCode, stdout, stderr, error) {
|
shellExec('powershell /?', function(exitCode, stdout, stderr, error) {
|
||||||
if (error || exitCode !== 0) {
|
if (error || exitCode !== 0) {
|
||||||
pw = scriptPW();
|
pw = scriptPW();
|
||||||
} else {
|
} else {
|
||||||
shellExec('powershell -Command "$text = read-host -AsSecureString;' +
|
shellExec('powershell -Command "$text = Read-Host -AsSecureString;' +
|
||||||
'$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($text);' +
|
'$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($text);' +
|
||||||
'[System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)"',
|
'[System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)"',
|
||||||
function(exitCode, stdout, stderr, error) {
|
function(exitCode, stdout, stderr, error) {
|
||||||
|
|
|
@ -155,9 +155,11 @@ function _readlineSync(options) { // options.display is string
|
||||||
if ((chunk = chunk.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, '')) === '')
|
if ((chunk = chunk.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, '')) === '')
|
||||||
{ continue; }
|
{ continue; }
|
||||||
|
|
||||||
if (!isEditable) {
|
if (!isEditable && (displayInput = chunk.replace(/[\r\n]/g, '')) !== '') {
|
||||||
displayInput = chunk.replace(/[\r\n]/g, '');
|
if (options.noEchoBack) {
|
||||||
if (options.noEchoBack) { displayInput = displayInput.replace(/./g, mask); }
|
displayInput = mask === '' ? '' :
|
||||||
|
(new Array(displayInput.length + 1)).join(mask);
|
||||||
|
}
|
||||||
if (displayInput !== '') { fs.writeSync(fdW, displayInput); }
|
if (displayInput !== '') { fs.writeSync(fdW, displayInput); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue