bun icon indicating copy to clipboard operation
bun copied to clipboard

Implement `tty.WriteStream`

Open Electroid opened this issue 2 years ago • 3 comments

Some of tty.WriteStream may already be implemented, but there are some missing pieces.

4 | const settings_1 = require("./settings");
5 | function termwidth(stream) {
6 |     if (!stream.isTTY) {
7 |         return 80;
8 |     }
9 |     const width = stream.getWindowSize()[0];
                      ^
TypeError: stream.getWindowSize is not a function. (In 'stream.getWindowSize()', 'stream.getWindowSize' is undefined)
      at termwidth (/node_modules/@oclif/core/lib/screen.js:9:18)
      at /node_modules/@oclif/core/lib/screen.js:19:34

This blocks the oclif CLI parser from working.

Electroid avatar Feb 15 '23 19:02 Electroid

Some related issues:

  • #1787
  • #1774
  • #2040 possibly

ThatOneBro avatar Feb 15 '23 19:02 ThatOneBro

I think this will be easy to do once I finish setting the framework up around TTY stuff in #2025

ThatOneBro avatar Feb 15 '23 19:02 ThatOneBro

Also, if someone wants to use oclif, here's a temporary workaround:

// HACK: https://github.com/oven-sh/bun/issues/2081
process.stdout.getWindowSize = () => [80, 80];
process.stderr.getWindowSize = () => [80, 80];

import { Command, Flags } from "@oclif/core";
// ...

Of course, we will fix this in Bun so you don't need to do this.

Electroid avatar Feb 15 '23 23:02 Electroid

FWIW this breaks many packages such as https://www.npmjs.com/package/clipanion sadly.

CyriacBr avatar May 25 '23 22:05 CyriacBr