fix chcp usage: exe->com. fix output parsing. see #130.

This commit is contained in:
Christopher Jeffrey 2015-04-25 15:19:22 -07:00
parent 0461a35219
commit f2d809d57b
1 changed files with 10 additions and 3 deletions

View File

@ -2139,7 +2139,8 @@ Tput.prototype.GetConsoleCP = function() {
}
try {
ccp = cp.execFileSync(process.env.WINDIR + '\\system32\\chcp.exe', [], {
// Produces something like: 'Active code page: 437\n\n'
ccp = cp.execFileSync(process.env.WINDIR + '\\system32\\chcp.com', [], {
stdio: 'pipe',
encoding: 'ascii'
});
@ -2147,9 +2148,15 @@ Tput.prototype.GetConsoleCP = function() {
;
}
if (!ccp) ccp = '-1';
ccp = /\d+/.exec(ccp);
return +ccp.trim();
if (!ccp) {
return -1;
}
ccp = +ccp[0];
return ccp;
};
/**