From cbed0b449a17cabd8c13ad45e1377b6b9f26c7cc Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 25 Apr 2015 16:59:31 -0700 Subject: [PATCH] GetConsoleCP fixes. see #130. --- lib/tput.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/tput.js b/lib/tput.js index 8af749e..2d98d25 100644 --- a/lib/tput.js +++ b/lib/tput.js @@ -2141,8 +2141,9 @@ Tput.prototype.GetConsoleCP = function() { try { // Produces something like: 'Active code page: 437\n\n' ccp = cp.execFileSync(process.env.WINDIR + '\\system32\\chcp.com', [], { - stdio: 'pipe', - encoding: 'ascii' + stdio: ['ignore', 'pipe', 'ignore'], + encoding: 'ascii', + timeout: 1500 }); } catch (e) { ; @@ -2156,6 +2157,12 @@ Tput.prototype.GetConsoleCP = function() { ccp = +ccp[0]; + // XXX Workaround: temporarily allow unicode on cp437. + // When CP is 65001, node throws on all output! + if (ccp === 437) { + ccp = 65001; + } + return ccp; };