Skip to content

Commit b96c3f0

Browse files
Migrate off of process global and openStdin (microsoft#25569)
## Description Based on https://stackoverflow.com/questions/33831978/unknown-method-process-openstdin#comment126485133_33832075 appears we do not need to resume the stream unless using "old" streams mode (from back in NodeJS 0.10), and can just use process.stdin instead of openStdin which was [as done in Node 0.3.3 back in 2011](https://github.com/nodejs/node/blob/43e4efdf210adb2cc3ba26518fd4588f9e0152ff/doc/changelogs/CHANGELOG_ARCHIVE.md#20110102-version-033-unstable). CheckPolicy's `--stdin` flag is the older user of this code, and was manually tested to work. As far as I can tell nothing uses this feature.
1 parent aa02b0b commit b96c3f0

File tree

1 file changed

+3
-2
lines changed
  • build-tools/packages/build-cli/src/commands/check

1 file changed

+3
-2
lines changed

build-tools/packages/build-cli/src/commands/check/policy.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { strict as assert } from "node:assert";
77
import * as fs from "node:fs";
88
import { EOL as newline } from "node:os";
99
import * as path from "node:path";
10+
import process from "node:process";
1011
import { Flags } from "@oclif/core";
1112

1213
import {
@@ -378,12 +379,12 @@ async function runFinalHandlers(
378379

379380
async function readStdin(): Promise<string> {
380381
return new Promise((resolve) => {
381-
const stdin = process.openStdin();
382+
const { stdin } = process;
382383
stdin.setEncoding("utf8");
383384

384385
let data = "";
385386
stdin.on("data", (chunk) => {
386-
data += chunk;
387+
data += chunk.toString("utf8");
387388
});
388389

389390
stdin.on("end", () => {

0 commit comments

Comments
 (0)