UNPKG

@kinvolk/headlamp-plugin

Version:

The needed infrastructure for building Headlamp plugins.

36 lines (35 loc) 1.35 kB
/** * Runs a shell command and returns an object that mimics the interface of a ChildProcess object returned by Node's spawn function. * * This function is intended to be used only when Headlamp is in app mode. * * @see handleRunCommand in app/electron/main.ts * * This function uses the desktopApi.send and desktopApi.receive methods to communicate with the main process. * @param command - The command to run. * @param args - An array of arguments to pass to the command. * @returns An object with `stdout`, `stderr`, and `on` properties. You can listen for 'data' events on `stdout` and `stderr`, and 'exit' events with `on`. * @example * * ```ts * const minikube = runCommand('minikube', ['status']); * minikube.stdout.on('data', (data) => { * console.log('stdout:', data); * }); * minikube.stderr.on('data', (data) => { * console.log('stderr:', data); * }); * minikube.on('exit', (code) => { * console.log('exit code:', code); * }); * ``` */ export declare function runCommand(command: 'minikube' | 'az', args: string[], options: {}): { stdout: { on: (event: string, listener: (chunk: any) => void) => void; }; stderr: { on: (event: string, listener: (chunk: any) => void) => void; }; on: (event: string, listener: (code: number | null) => void) => void; };