Skip to content

Commit

Permalink
Use get-stdin to read the stdin
Browse files Browse the repository at this point in the history
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 :)
  • Loading branch information
fsouza committed Apr 11, 2024
1 parent fc0f74b commit 5bb2c8a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"dependencies": {
"core_d": "^6.1.0",
"get-stdin": "^9.0.0",
"prettier": "^3.2.5"
},
"files": [
Expand Down
5 changes: 2 additions & 3 deletions src/prettierd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { access, mkdir } from "node:fs/promises";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { promisify } from "node:util";

// @ts-ignore
import { version } from "../package.json";
import { displayHelp } from "./args";
import { DebugInfo, getDebugInfo, stopAll } from "./service";
import getStdin from "get-stdin";

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

type Action =
Expand Down Expand Up @@ -122,7 +121,7 @@ async function main(args: string[]): Promise<void> {
{},
),
},
await readFile(process.stdin.fd, { encoding: "utf-8" }),
await getStdin(),
);
}

Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ fill-range@^7.0.1:
dependencies:
to-regex-range "^5.0.1"

get-stdin@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-9.0.0.tgz#3983ff82e03d56f1b2ea0d3e60325f39d703a575"
integrity sha512-dVKBjfWisLAicarI2Sf+JuBE/DghV4UzNAVe9yhEJuzeREd3JhOTE9cUaJTeSa77fsbQUK3pcOpJfM59+VKZaA==

glob-parent@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
Expand Down

0 comments on commit 5bb2c8a

Please sign in to comment.