0.1.2 • Published 7 years ago

spawnp v0.1.2

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

spawnp

node spawn but return promise.

Build Status

Coverage Status

install

npm i spawnp --save

example

let spawnp = require('spawnp');

spawnp('echo', ['123']).then(() => {
    // finshed
}).catch(() => {
    // erorred
});

api

spawnp(command[, args][, options][, extra])

  • command

Just like spawn's command, but support arg in command, like echo 123

spawnp('echo 123', ['456']); // 123 456\n
  • args

Just like spawn's args

  • options

Just like spawn's options

  • extra

Object, {onChild, stdout, stderr}, see next.

onChild

spawnp('echo', ['123'], null, {
    onChild: (child) => {
        child.stdout.on('data', (chunk) => {
            console.log(chunk.toString()); //123\n
        });
    };
}); // return a promise

stdout

spawnp('echo', ['123'], null, {
    stdout: true // config stdout option
}).then(({
    stdouts // then will get stdout chunks
}) => {
    console.log(stdouts.join('')); //'123\n';
});

stderr

spawnp('ls', ['oooooooooo'], null, {
    stderr: true
}).catch(({
    stderrs
}) => {
    console.log(stderrs.join(''));
});
0.1.2

7 years ago

0.1.0

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago