Skip to content
Advertisement

How to use child-process-promise

JavaScript

What I want is to add some processing after command produced output in stdout. So finally I want to create a function to use like this:

JavaScript

The function should use promise from child-process-promise, wait until successful result produced and return promise for processing data.

Advertisement

Answer

Welcome to Stack Overflow @ScHoolboy.

I cansuggest you use a basic child-process module from Node.js and promising it yourself in the following way

JavaScript

Where:

  • cmd – command, for example, “echo”
  • args: array of arguments, for example [“Hello world”]

You can call the function as RunCommandAndProcess if you need 🙂

Example of usage:

JavaScript

Or

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement