From cf29238c9aec606af3b5a23d81389e94ab167fa2 Mon Sep 17 00:00:00 2001 From: anseki Date: Thu, 12 Mar 2015 11:03:04 +0900 Subject: [PATCH] Rename `read.cs.js` -> `read-s.cs.js` --- README.md | 4 ++-- lib/{read.cs.js => read-s.cs.js} | 40 ++++++++++++++++---------------- lib/read.bat | 2 +- lib/read.sh | 2 +- package.json | 2 +- 5 files changed, 25 insertions(+), 25 deletions(-) rename lib/{read.cs.js => read-s.cs.js} (93%) diff --git a/README.md b/README.md index 8c9bce8..5838743 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ answer = readlineSync.question([query[, options]]) ``` Display the `query` to the user, and then return the user's response after it has been typed and Enter key was pressed. -You can specify `options` (see [Options](#options)). **You should consider `noEchoBack` option, if the user inputs the secret text (e.g. password).** +You can specify `options` (see [Options](#options)). **If the user inputs the secret text (e.g. password), you should consider `noEchoBack` option.** The `query` may be string, or may not be (e.g. number, Date, Object, etc.). This is converted to string (i.e. `toString` method is called) before it is displayed. @@ -45,7 +45,7 @@ input = readlineSync.prompt([options]) ``` Display the current prompt (See `setPrompt` method) to the user, and then return the user's response after it has been typed and Enter key was pressed. -You can specify `options` (see [Options](#options)). **You should consider `noEchoBack` option, if the user inputs the secret text (e.g. password).** +You can specify `options` (see [Options](#options)). **If the user inputs the secret text (e.g. password), you should consider `noEchoBack` option.** ### setPrompt diff --git a/lib/read.cs.js b/lib/read-s.cs.js similarity index 93% rename from lib/read.cs.js rename to lib/read-s.cs.js index f198def..1340a93 100644 --- a/lib/read.cs.js +++ b/lib/read-s.cs.js @@ -1,20 +1,20 @@ -/* global WScript:false */ - -var oExec; - -// exit-code is not returned even if an error is thrown. -try { - WScript.StdOut.Write(WScript.CreateObject('ScriptPW.Password').GetPassword() - // Bug? Illegal data may be returned when user types before initializing. - .replace(/[\u4000-\u40FF]/g, function(chr) { - var charCode = chr.charCodeAt(0); - return charCode >= 0x4020 && charCode <= 0x407F ? - String.fromCharCode(charCode - 0x4000) : ''; - })); -} catch (e) { - WScript.StdErr.Write(e.description); - WScript.Quit(1); -} - -oExec = WScript.CreateObject('WScript.Shell').Exec('cmd /c echo; >CON'); -while (oExec.Status === 0) { WScript.Sleep(100); } +/*jshint wsh:true */ + +var oExec; + +// exit-code is not returned even if an error is thrown. +try { + WScript.StdOut.Write(WScript.CreateObject('ScriptPW.Password').GetPassword() + // Bug? Illegal data may be returned when user types before initializing. + .replace(/[\u4000-\u40FF]/g, function(chr) { + var charCode = chr.charCodeAt(0); + return charCode >= 0x4020 && charCode <= 0x407F ? + String.fromCharCode(charCode - 0x4000) : ''; + })); +} catch (e) { + WScript.StdErr.Write(e.description); + WScript.Quit(1); +} + +oExec = WScript.CreateObject('WScript.Shell').Exec('cmd /c echo; >CON'); +while (oExec.Status === 0) { WScript.Sleep(100); } diff --git a/lib/read.bat b/lib/read.bat index dc8ad53..638c0f8 100644 --- a/lib/read.bat +++ b/lib/read.bat @@ -47,7 +47,7 @@ powershell /? >NUL 2>&1 :: Win XP and Server2003 have `ScriptPW` (`scriptpw.dll`). :: In the systems that don't have both, an error is thrown. if ERRORLEVEL 1 ( - set "exec_line=cscript //nologo "%~dp0read.cs.js"" + set "exec_line=cscript //nologo "%~dp0read-s.cs.js"" ) else ( set "exec_line=powershell -Command "$text = read-host -AsSecureString; ^ $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR^($text^); ^ diff --git a/lib/read.sh b/lib/read.sh index be9ebd2..3092b78 100644 --- a/lib/read.sh +++ b/lib/read.sh @@ -1,4 +1,4 @@ -# Silent Read +# Silent Read : emulate `read -s` of bash/zsh read_s() { stty --file=/dev/tty -echo echonl 2>/dev/null || \ stty -F /dev/tty -echo echonl 2>/dev/null || \ diff --git a/package.json b/package.json index 104545b..2d539c9 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "readline-sync", "version": "0.7.6", "title": "readlineSync", - "description": "Synchronous Readline", + "description": "Synchronous Readline for interactively running to have a conversation with the user via a console(TTY).", "keywords": [ "readline", "synchronous",