Skip to content

pnpm output loses colors when create-vinext-app initializing the project #2863

Description

@NriotHrreion

Summary

When installing dependencies for the new project with create-vinext-app, the output printed by pnpm loses its ANSI colors and is displayed as plain text.

The same pnpm commands normally produce colored output when run directly in a terminal, so the CLI appears to be preventing or stripping color output when spawning pnpm.

Reproduction

Start a new project with create-vinext-app

pnpm create vinext-app@latest test-app

Choose the project configurations and install the project dependencies, then you can see the pnpm output just loses its colors.

Image

Expected behavior

Image

Possible root cause

pnpm dependencies installing process is spawned by installDeps() with exec() function, and the stdio is set to inherit.

return (
(await exec(`${installCmd} ${depsStr}`, {
cwd: root,
stdio: "inherit",
})) ?? ""

However, exec() accepts the parameter stdio and just doesn't pass it to the spawn(). The stdio is actually hard-coded as ["inherit", "pipe", "pipe"].

const exec =
options._exec ??
((cmd: string, opts: { cwd: string; stdio: string }) =>
new Promise<string>((resolve, reject) => {
const child = spawn(cmd, {
cwd: opts.cwd,
shell: true,
stdio: ["inherit", "pipe", "pipe"],
});

Notes

The hard-coded pipe is for detecting approve builds error (related #2279). So fixing this issue can be quite tricky.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions