Skip to main content

Command Palette

Search for a command to run...

Today's npm package: child-process-ext

Updated
โ€ข1 min read
P

I am developer from India currently based in Berlin, Germany.

I am very interested in Design, though I don't design ๐Ÿ˜‰ I take care of it while making my apps.

Photography, videography and having random conversation over beer are my activities of spare time. Timelapses and hyperlapses make me wonder all the time ๐Ÿ˜Š

Today's npm package is child-process-ext

When creating CLI tools, you might wanna use other CLI tools and not have the luxury of npm package around those tools.

In such cases, you would need to create a child process with specific CLI command and get the result from that process.

And to create child process, we have node.js's spawn function

Currently spawn functions are not promisified and today's package child-process-ext will let you do the promisified work on spawned processes.

Here's how to use it:

const spawn = require('child-process-ext/spawn');

const proc = spawn('ls');

proc.then(op => console.log(op.stdoutBuffer.toString()))

and generates following output:

Stay tuned for tomorrow's package of the Day.

More from this blog

P

Pankaj Patel - @heypankaj_

63 posts

Sharing my learnings and thoughts on Blogging, Personal Branding and Programming