package
Multiplexes the output of several commands.
npm install multiplexerGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 11 packages.
1001.0 kB
Includes dependencies.
Takes a filename as an argument. It will then treat each line from this file as a command and spawn a process with it. Finally it will multiplex the output of each of those processes, prefixing each line with the PID of that process.
npm install -g multiplexerecho "\
while [ 1 ] ; do echo beep ; sleep 1 ; done
while [ 1 ] ; do echo boop ; sleep 1 ; done
while [ 1 ] ; do echo baap ; sleep 1 ; done" > example-commands
multiplexer example-commandsOutput:
25242 beep
25244 boop
25246 baap
25242 beep
25244 boop
25246 baap
25242 beep
25244 boop
25246 baapnpm install multiplexerconst multiplexer = require('multiplexer')
multiplexer([
'while [ 1 ] ; do echo beep ; sleep 1 ; done',
'while [ 1 ] ; do echo beep ; sleep 1 ; done',
'while [ 1 ] ; do echo beep ; sleep 1 ; done'
])Instead of a string, each command can be an object with the following fields:
cwd ... Set working directoryenv ... Set of environment key-value pairsuid ... Run as User IDgid ... Run as Group IDdetached ... Detach from parent processalias ... Custom log prefix (default: process id)waitFor ... Wait for process to print given string to stdout before spawning next process