-
Notifications
You must be signed in to change notification settings - Fork 300
Closed
Description
- Version: 10.2.1
- Platform: Windows 10 64-bit
- Subsystem: child_process.exec()
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);
- OUTPUT:
stdout: test
Metadata
Metadata
Assignees
Labels
No labels