-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed bug that results in the command-line version of pyright not han…
…dling long file lists provided via stdin. This addresses #9583.
- Loading branch information
Showing
2 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* streamUtils.ts | ||
* Copyright (c) Microsoft Corporation. | ||
* Licensed under the MIT license. | ||
* | ||
* Utility functions for dealing with standard IO streams in node. | ||
*/ | ||
|
||
import { stdin } from 'process'; | ||
|
||
export async function getStdinBuffer() { | ||
if (stdin.isTTY) { | ||
return Buffer.alloc(0); | ||
} | ||
|
||
const result = []; | ||
let length = 0; | ||
|
||
for await (const chunk of stdin) { | ||
result.push(chunk); | ||
length += chunk.length; | ||
} | ||
|
||
return Buffer.concat(result, length); | ||
} | ||
|
||
export async function getStdin() { | ||
const buffer = await getStdinBuffer(); | ||
return buffer.toString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters