LogoPear Docs
ReferencesBareModules

bare-sidecar

Start and manage Bare sidecar processes from Node.js and Electron

stable

bare-sidecar — Start and manage Bare sidecar processes from Node.js and Electron.

npm i bare-sidecar

Usage

In the host process:

const Sidecar = require('bare-sidecar')

const sidecar = new Sidecar(require.resolve('./entry'))

sidecar
  .on('exit', (code, status) => {
    // The sidecar process exited
  })
  .on('data', (data) => {
    // Received data from the sidecar over IPC
  })
  .write('Hello sidecar')

In the sidecar entry (entry.js), the IPC channel is available as a stream on Bare.IPC:

Bare.IPC.on('data', (data) => Bare.IPC.write(data))

API

Sidecar

new Sidecar(entry: string, args?: string[], opts?: SidecarOptions)

Source

Spawn a bundled Bare runtime running entry and return a Sidecar. entry is the path to the module to run, typically resolved with require.resolve(). args is an array of additional command line arguments passed to the process. options is reserved for future use.

Overloads:

new Sidecar(entry: string, args?: string[], opts?: SidecarOptions)
new Sidecar(entry: string, opts?: SidecarOptions)

Parameters

ParameterTypeDefaultDescription
entrystringPath to the module the sidecar process runs, typically resolved with require.resolve().
args?string[]Additional command-line arguments passed to the process (default []).
opts?SidecarOptionsReserved for future use.

stderr: Pipe | null

Source

The readable standard error stream of the underlying process.

stdin: Pipe | null

Source

The writable standard input stream of the underlying process.

stdout: Pipe | null

Source

The readable standard output stream of the underlying process.

Types

SidecarEvents

interface SidecarEvents extends DuplexEvents {
  exit: [code: number | null, signalCode: string | null]
}
Source

SidecarOptions

interface SidecarOptions {}
Source

See also

On this page