README
std-cb
Extended version of JoelBCarter/std-pour.
(Oh and this one has typescript deffinition support)
Usage
This library is great for chaining commands using promises, but seeing the output in real-time.
const StdCbModule = require('std-cb');
const StdCb = new stdCbModule();
StdCb.pour('ping', ['8.8.8.8', '-c', '4']).then(code =>
console.log(`Error Code: ${code}`)
);
This module wraps child_process.spawn
so should be drop-in replacement (function signature-compatable) for any code that is using it.
const { spawn } = require('child_process');
const StdCbModule = require('std-cb');
const StdCb = new stdCbModule();
const options = {
cwd: '/usr',
env: process.env,
};
const ls1 = spawn('ls', ['-al'], options);
const ls2 = StdCb.pour('ls', ['-al'], options);
API
(See std-pour as this extends it)
Propreties
defaultStdout = process.stdout.write (1.2.1+)
Default function to call for logging stdout output
defaultStderr = process.stderr.write (1.2.2+)
Default function to call for logging stderr output
Methods
pour/pourConsole
std-pour#pourpourconsole but with the following syntax:
stdPour.pour(
cmd,
args,
opts,
(stdout = defaultStdout),
(stderr = defaultStderr)
);
stdPour.pourConsole(
cmd,
args,
opts,
(stdout = defaultStdout),
(stderr = defaultStderr)
);