提交 9234a7c9 编写于 作者: J Joao Moreno

🐛 dont call iconv with unsupported encodings

fixes #25359
上级 facdcded
......@@ -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[] = [];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册