0.1.0 • Published 6 years ago

realtime-stdout v0.1.0

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

realtime-stdout

Build Status

Node.js realtime stdout.

How to use

yarn add realtime-stdout

Example

const realtimeStdout = require('realtime-stdout')

const command = 'ls'
const stdout = ''

const cp = realtimeStdout(command, [], {}, data => (stdout += data))

cp.on('close', () => {
  console.log(stdout)
})

API

Here is the realtimeStdout's definition:

/// <reference types="node" />
import { SpawnOptions, ChildProcess } from 'child_process';
export default function realtimeStdout(command: string, args?: ReadonlyArray<string>, options?: SpawnOptions, onStdout?: (data: string) => void): ChildProcess;

The first three arguments are consistent with child_process.spawn(command[, args][, options]).

The onStdout is a callback function which receive stdout data as argument. You can pass your own opertions in it.

License

MIT