fix chcp usage: exe->com. fix output parsing. see #130.
This commit is contained in:
parent
0461a35219
commit
f2d809d57b
13
lib/tput.js
13
lib/tput.js
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue