Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upNo stdout event fired on 'data' for child_process #35680
Comments
|
@binrusas85 After removing the Typescript part to try your code, the stdout event does get fired and your static function does return the output of |


I implemented a static method that takes two input parameters: (1) script/command (2) args to be passed to the given script/command. The issue is that I'm not able to get the output. Note I'm running on a mac machine if that makes sense.
Here is my code:
`import { spawn } from 'child_process';
import { StringBuilder } from 'typescript-string-operations';
export class Exec {
/**
* To execute a given command with its args in a separate process
* without creating a new shell
* @static
* @param {string} cmd
* @param {string[]} args
* @returns {Promise}
* @memberof Exec
*/
static exec(cmd:string, args:string[]):Promise {
return new Promise((resolve, reject) => {
try{
let out:StringBuilder = new StringBuilder();
let child = spawn(cmd, args);
}
// try to run the following line inside a function with 'async' word
let p = await Exec.exec('ps', ['ax']);
`