mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 19:48:37 -05:00
Merge from vscode 2cd495805cf99b31b6926f08ff4348124b2cf73d
This commit is contained in:
committed by
AzureDataStudio
parent
a8a7559229
commit
1388493cc1
@@ -4,8 +4,8 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as minimist from 'minimist';
|
||||
import * as os from 'os';
|
||||
import { localize } from 'vs/nls';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
|
||||
export interface ParsedArgs {
|
||||
_: string[];
|
||||
@@ -382,7 +382,7 @@ export function buildHelpMessage(productName: string, executableName: string, ve
|
||||
help.push(`${localize('usage', "Usage")}: ${executableName} [${localize('options', "options")}][${localize('paths', 'paths')}...]`);
|
||||
help.push('');
|
||||
if (isPipeSupported) {
|
||||
if (os.platform() === 'win32') {
|
||||
if (isWindows) {
|
||||
help.push(localize('stdinWindows', "To read output from another program, append '-' (e.g. 'echo Hello World | {0} -')", executableName));
|
||||
} else {
|
||||
help.push(localize('stdinUnix', "To read from stdin, append '-' (e.g. 'ps aux | grep code | {0} -')", executableName));
|
||||
|
||||
@@ -46,13 +46,19 @@ export async function readFromStdin(targetPath: string, verbose: boolean): Promi
|
||||
|
||||
let encoding = await resolveTerminalEncoding(verbose);
|
||||
|
||||
const iconv = await import('iconv-lite');
|
||||
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 converterStream = iconv.decodeStream(encoding);
|
||||
process.stdin.pipe(converterStream).pipe(stdinFileStream);
|
||||
const decoder = iconv.getDecoder(encoding);
|
||||
process.stdin.on('data', chunk => stdinFileStream.write(decoder.write(chunk)));
|
||||
process.stdin.on('end', () => {
|
||||
stdinFileStream.write(decoder.end());
|
||||
stdinFileStream.end();
|
||||
});
|
||||
process.stdin.on('error', error => stdinFileStream.destroy(error));
|
||||
process.stdin.on('close', () => stdinFileStream.close());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user