I'm trying to fix a bug for a VSCode extension (twsx.vs.language.cmake) which uses NodeJS child_process
to capture stdout from cmake commands to provide VSCode with auto-completion data. The problem is that child_process.stdout.on('data',...)
is never invoked for any cmake command.
environment:
- OS: Kubuntu 22.04
- VSCode: 1.74.3 (snap)
- CMake: 3.25.2 (snap)
I created a simple test script for the problem:
var spawn = require('child_process').spawn;
var cmd = spawn("cmake", ["--help-command-list"]);
cmd.stdout.on('data', (data) => console.log(`Stdout: ${data}`));
cmd.stderr.on('data', (data) => console.log(`Stderr: ${data}`));
cmd.on('error', (err) => console.log(`Error: ${err}`));
cmd.on('close', (code, signal) =>
console.log(`Close; code: ${code}; signal: ${signal}`));
The script above
- does work outside of VSCode (using any terminal)
- does work for any application but cmake inside VSCode terminal
- does not work inside VSCode terminal (no errors, success exit code but no stdout data captured)
Executing cmake directly inside a VSCode terminal works as expected.
Question: How is it possible that child_process.spawn("cmake").stdout.on('data', ...)
behaves different inside VSCode terminal and a native terminal ?