Skip to content

terminal color goes wrong after spawn #3028

Closed as not planned
Closed as not planned

Description

@ui3o

Syndrome

On windows after spawn the terminal color are not displayed well.

  • Node.js Version: v12.19.0
  • OS: windows 10
  • Scope (install, code, runtime, meta, other?): runtime
  • Module (and version) (if relevant): spawn

✔ The first colored line display well but after the spawn
✖ The second colored line wrong

const { spawn } = require('child_process');

async function test() {
    console.log('\x1b[36m%s\x1b[0m', 'I am cyan');
    await run('echo Hello world!');
    console.log('\x1b[36m%s\x1b[0m', 'I am cyan');

    async function run(scrpt) {
        const cmd = spawn('bash', ['-c', scrpt], { stdio: 'inherit' });
        return new Promise((resolve) => {
            cmd.on('close', (code) => resolve(code));
        });
    }
}

test();
  • Cygwin is installed
  • bash is available on the path

image

Anybody knows what is wrong with this code?

Thank you!

Activity

  1. bmuenzenmeyer commented on Nov 11, 2022

    @bmuenzenmeyer
    Contributor

    This question is idle and left unanswered for years now.

    • Does the behavior persist if you upgrade to a new version of Node.js? This reported version is end of life.
    • Have you attempted to ask this question within other communities, such as stackoverflow?

    I am going to circle back in a couple weeks to see if we can close as no-longer relevant.


    FWIW, I ran the above in a Node 16.X REPL and got correct behavior:

    image

  2. bmuenzenmeyer commented on Dec 2, 2022

    @bmuenzenmeyer
    Contributor

    closing per the above plan

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

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