Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postinstall script ansi color doesn't work #6124

Open
tjx666 opened this issue Feb 22, 2023 · 12 comments
Open

postinstall script ansi color doesn't work #6124

tjx666 opened this issue Feb 22, 2023 · 12 comments

Comments

@tjx666
Copy link

tjx666 commented Feb 22, 2023

pnpm version: 7.27.1

Code to reproduce the issue: https://github.com/tjx666/pnpm-postinstll-script-ansi-issue

Expected behavior:

after pnpm install:

image

Actual behavior:

image

Additional information:

System:
    OS: macOS 13.2.1
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
    Memory: 270.04 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.14.1 - ~/Library/Caches/fnm_multishells/9738_1677093635011/bin/node
    npm: 9.5.0 - ~/Library/Caches/fnm_multishells/9738_1677093635011/bin/npm
@zkochan
Copy link
Member

zkochan commented Feb 23, 2023

We currently collapse the output of postinstall scripts. Colours only work if stdio inherit is used, when executing the child process for postinstall. So in order to do it we'd have to change how we print the output of the scripts.

@tjx666
Copy link
Author

tjx666 commented Mar 7, 2023

@zkochan So, why not

@ai
Copy link
Contributor

ai commented Jul 13, 2023

It will be very helpful for pnpm run /^test:/ use case. In that case user see the output of the scripts more often.

@ai
Copy link
Contributor

ai commented Jul 13, 2023

@zkochan if you have a plan how to do it, I can send a developer do implement it.

@zkochan
Copy link
Member

zkochan commented Jul 13, 2023

We have pushed a fix for this recently. Did that not solve the issue?

Related PR: #4559
Related issue: #2148

@ai
Copy link
Contributor

ai commented Jul 13, 2023

Most of colors libraries (chalk, picoolors, colorette, kleur) don’t detect color support in collapsed mode because require('tty').istty(1) returns false.

If I do console.log('\x1b[32msimple\x1b[39m') without color support detection it will work great.

@zkochan
Copy link
Member

zkochan commented Jul 13, 2023

You can force colours.

#2148 (comment)

@ai
Copy link
Contributor

ai commented Jul 14, 2023

You can force colours

Yes, it’s fine for short-term solution.

What do you think of running scripts with node-pty as a long-term solution? I can ask somebody to send PR if you think it is safe enouph (at least nx and other big companies use it).

@zkochan
Copy link
Member

zkochan commented Jul 14, 2023

nx uses it for the same purpose?

@ai
Copy link
Contributor

ai commented Jul 14, 2023

Oops, it was NxShell, not nx. But they have a solid list of users (mostly terminals like Terminal panel in VS Code).

@zkochan
Copy link
Member

zkochan commented Jul 14, 2023

I see that it has some built dependencies

# Install dependencies and build C++
npm install

This is problematic. We have many installation methods and currently they are simple because don't need a build step. But this new dependency would break a lot of things.

I don't think we can use it.

@ai
Copy link
Contributor

ai commented Jul 14, 2023

OK, colorless output is not big deal. Let’s wait for some solution in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants