src/vs/platform/environment/node/stdin.ts/readFromStdin
export async function readFromStdin(targetPath: string, verbose: boolean): Promise<void> {

	// open tmp file for writing
	const stdinFileStream = fs.createWriteStream(targetPath);

	let encoding = await resolveTerminalEncoding(verbose);

	const iconv = await import('iconv-lite-umd');
	if (!iconv.encodingExists(encoding)) {
		console.log(`Unsupported terminal encoding: ${encoding}, falling back to UTF-8.`);
		encoding = 'utf8';
	}

	// Pipe into tmp file using terminals encoding
	const decoder = iconv.getDecoder(encoding);
	process.stdin.on('data', chunk => stdinFileStream.write(decoder.write(chunk)));
	process.stdin.on('end', () => {
		const end = decoder.end();
		if (typeof end === 'string') {
			stdinFileStream.write(end);
		}
		stdinFileStream.end();
	});
	process.stdin.on('error', error => stdinFileStream.destroy(error));
	process.stdin.on('close', () => stdinFileStream.close());
}