You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scenario:
I was creating a nodejs library now that is nearly complete i just want to export it but problem is how to access stdout of exec() outside of it's scope.
Code:
let data = "";
const { exec } = require('child_process');
exec('echo test', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
data = stdout;
console.log(`stdout: ${stdout}`);
});
console.log(data);