0.5.5 • Published 4 years ago

p-spawn v0.5.5

Weekly downloads
62
License
MIT
Repository
github
Last release
4 years ago

Yet another spawn promise. (Zero dependency!)

  • Promisified child_process.spawn, with more options
  • stdout/stderr to console by default.
  • Route stdout or stderr to file.
  • Can run spawn as detached (promise will return with handle)
  • Typescript definitions

Notes:

  • Require node.js > 8.0 (if you need more support, log ticket)
  • Warning: From 0.4.0 needs to be imported as { spawn }
import { spawn } from 'p-spawn'
// or `const {spawn } from 'p-spawn'

await spawn(cmd, args, opts); // return Promise

doc

Examples:

const { spawn } = require("p-spawn");


async function test(){
  // will console log the stdout and stderr
  await spawn("echo", ["hello world"]);


  // will not console log the stdout but rather to forward in onStdout
  var txt = [];
  await spawn("echo", ["hello world"], {
    onStdout: (data) => {
      txt.push(data.toString());
    }
  });
  console.log(txt.join("\n"));

  // we an pass spawn options as well
  await spawn("pwd", {
    cwd: "./test",
    onStdout: (data) => {
      txt.push(data.toString());
    }
  });

  // we an pass spawn options as well
  var result = await spawn("echo",["hello world"], {capture: "stdout"});

  console.log(result.stdout); // "hello world"  
}
0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago