🐛 dont call iconv with unsupported encodings

fixes #25359
This commit is contained in:
Joao Moreno 2017-04-26 16:58:12 +02:00
parent facdcded9d
commit 9234a7c97c

View file

@ -171,6 +171,9 @@ async function exec(child: cp.ChildProcess, options: any = {}): Promise<IExecuti
disposables.push(toDisposable(() => ee.removeListener(name, fn)));
};
let encoding = options.encoding || 'utf8';
encoding = iconv.encodingExists(encoding) ? encoding : 'utf8';
const [exitCode, stdout, stderr] = await Promise.all<any>([
new Promise<number>((c, e) => {
once(child, 'error', e);
@ -179,7 +182,7 @@ async function exec(child: cp.ChildProcess, options: any = {}): Promise<IExecuti
new Promise<string>(c => {
const buffers: Buffer[] = [];
on(child.stdout, 'data', b => buffers.push(b));
once(child.stdout, 'close', () => c(iconv.decode(Buffer.concat(buffers), options.encoding || 'utf8')));
once(child.stdout, 'close', () => c(iconv.decode(Buffer.concat(buffers), encoding)));
}),
new Promise<string>(c => {
const buffers: Buffer[] = [];