Skip to content

Commit 5bb2c8a

Browse files
committed
Use get-stdin to read the stdin
It's not _really_ a new dependency as prettier already depends on it, but let's bring it in. I suspect that users are running into weird encoding issues in #694 (and maybe #698). Rather than spending too much time on this, I'm just taking a shortcut: users confirm that they cannot reproduce the issue in `prettier`, so let's read stdin the same `prettier` does :)
1 parent fc0f74b commit 5bb2c8a

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
},
3131
"dependencies": {
3232
"core_d": "^6.1.0",
33+
"get-stdin": "^9.0.0",
3334
"prettier": "^3.2.5"
3435
},
3536
"files": [

src/prettierd.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import { access, mkdir } from "node:fs/promises";
22
import fs from "node:fs";
33
import os from "node:os";
44
import path from "node:path";
5-
import { promisify } from "node:util";
65

76
// @ts-ignore
87
import { version } from "../package.json";
98
import { displayHelp } from "./args";
109
import { DebugInfo, getDebugInfo, stopAll } from "./service";
10+
import getStdin from "get-stdin";
1111

12-
const readFile = promisify(fs.readFile);
1312
const coredCommands = ["restart", "start", "status"];
1413

1514
type Action =
@@ -122,7 +121,7 @@ async function main(args: string[]): Promise<void> {
122121
{},
123122
),
124123
},
125-
await readFile(process.stdin.fd, { encoding: "utf-8" }),
124+
await getStdin(),
126125
);
127126
}
128127

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ fill-range@^7.0.1:
144144
dependencies:
145145
to-regex-range "^5.0.1"
146146

147+
get-stdin@^9.0.0:
148+
version "9.0.0"
149+
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-9.0.0.tgz#3983ff82e03d56f1b2ea0d3e60325f39d703a575"
150+
integrity sha512-dVKBjfWisLAicarI2Sf+JuBE/DghV4UzNAVe9yhEJuzeREd3JhOTE9cUaJTeSa77fsbQUK3pcOpJfM59+VKZaA==
151+
147152
glob-parent@^5.1.2:
148153
version "5.1.2"
149154
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"

0 commit comments

Comments
 (0)