Prevent workspaces-enabled pnpm from manipulating stdout?

17 Views Asked by At

I decided to try using workspaces in my multi-package repo, managed by pnpm. But I quickly ran into a problem when running pnpm install:

. postinstall$ <COMMANDS HERE>
[20 lines collapsed]
│ ../.. postinstall: <CUSTOM OUTPUT HERE>
<...>
│ ../.. postinstall: <CUSTOM OUTPUT CONTINUED HERE>
└─ Running...

I have custom postinstall scripts that apply color to stdout and manipulate the cursor position to display progress on certain tasks. This works fine with pnpm i if workspaces are disabled (i.e., if pnpm-workspace.yaml is absent).

But with workspaces, pnpm tries to apply some fancy cursor-manipulation and formatting of its own, and it results in completely garbage output from my custom scripts. How can I prevent pnpm from doing this?

I've tried all --reporter options to no luck, and --reporter-hide-prefix appears to be only for pnpm run.

1

There are 1 best solutions below

1
Zoltan Kochan On

There are a couple of ways.

You can use --aggregate-output, in that case the output will be aggregated in memory and printed once when the child process finishes.

You can use --stream and the output will be not grouped just printed immediately.

--reporter=append-only should also work. It will probably be similar to the --stream output.