提交 ec312033 编写于 作者: B Benjamin Pasero

cli - remove stdin argument properly

上级 0ea609f9
......@@ -142,17 +142,20 @@ export async function main(argv: string[]): TPromise<any> {
// 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`);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册