Skip to content

terminal color goes wrong after spawn #3028

@ui3o

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!

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