From ec312033101f200dbda221b3b50e92a6557b6183 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 28 Dec 2017 11:04:45 +0100 Subject: [PATCH] cli - remove stdin argument properly --- src/vs/code/node/cli.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/vs/code/node/cli.ts b/src/vs/code/node/cli.ts index 5344e8a5f54..b47a0015178 100644 --- a/src/vs/code/node/cli.ts +++ b/src/vs/code/node/cli.ts @@ -142,17 +142,20 @@ export async function main(argv: string[]): TPromise { // Windows workaround for https://github.com/nodejs/node/issues/11656 } + const readFromStdin = args._.some(a => a === '-'); + if (readFromStdin) { + // remove the "-" argument when we read from stdin + args._ = args._.filter(a => a !== '-'); + argv = argv.filter(a => a !== '-'); + } + let stdinFilePath: string; if (stdinWithoutTty) { // Read from stdin: we require a single "-" argument to be passed in order to start reading from // stdin. We do this because there is no reliable way to find out if data is piped to stdin. Just // checking for stdin being connected to a TTY is not enough (https://github.com/Microsoft/vscode/issues/40351) - if (args._.length === 1 && args._[0] === '-') { - - // remove the "-" argument when we read from stdin - args._ = []; - argv = argv.filter(a => a !== '-'); + if (args._.length === 0 && readFromStdin) { // prepare temp file to read stdin to stdinFilePath = paths.join(os.tmpdir(), `code-stdin-${Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 3)}.txt`); -- GitLab