Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Add ability to get child process from the exec function #326

Open
Tzahi12345 opened this issue Aug 26, 2020 · 1 comment
Open

Add ability to get child process from the exec function #326

Tzahi12345 opened this issue Aug 26, 2020 · 1 comment

Comments

@Tzahi12345
Copy link

I was hoping there would be a way to get the child process from the exec function (calling the binary directly), it only returns undefined. Here's the relevant code:

const execa = universalify.fromPromise(require('execa'))

function youtubeDl (args, options, cb) {
  return execa(ytdlBinary, args, options, function done (err, output) {
    if (err) return cb(err)
    return cb(null, output.stdout ? output.stdout.trim().split(/\r?\n/) : undefined)
  })
}

This was apparently possible before (see this commit), but execFile has since been replaced with execa.

I played around with it for a bit and it looks like universalify.fromPromise makes it so the return result is always undefined. When execa is imported normally (w/o the universalify call), the videos don't download but the child process is returned.

I'm not crazy familiar with the universalify library or even execa, so I'd appreciate some help on how we can make this possible. I added some links below for additional reading.


Additional reading:

@jai-dewani
Copy link

Use can use fork or spawn if you want to work with children, the solution you are looking for but they return a child_process which can be used to check status, communicate and even terminate the process using the child_process object.

Hope this helps

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants