Skip to main content

Type Alias: PluginRunCommand

type PluginRunCommand = (command: string, args: string[], options: Record<string, never>) => ReturnType<typeof runCommand>;

Defined in: components/App/runCommand.ts:52

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.

Parameters​

ParameterTypeDescription
commandstringThe command to run.
argsstring[]An array of arguments to pass to the command.
optionsRecord<string, never>Additional options for the command.

Returns​

ReturnType<typeof runCommand>

An object with stdout, stderr, and on properties. You can listen for 'data' events on stdout and stderr, and 'exit' events with on.

See​

handleRunCommand in app/electron/main.ts

This function uses the desktopApi.send and desktopApi.receive methods to communicate with the main process.

Example​

How it can be used in a plugin:

  import type { PluginRunCommand } from '@kinvolk/headlamp-plugin/lib';
declare const pluginRunCommand: PluginRunCommand;
const minikube = pluginRunCommand('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);
});