Function: runCommand()
function runCommand(
command: "minikube" | "az",
args: string[],
options: object): object
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
Parameter | Type | Description |
---|---|---|
command | "minikube" | "az" | The command to run. |
args | string [] | An array of arguments to pass to the command. |
options | object | - |
Returns
object
An object with stdout
, stderr
, and on
properties. You can listen for 'data' events on stdout
and stderr
, and 'exit' events with on
.
on()
on: (event: string, listener: (code: number | null) => void) => void;
Parameters
Parameter | Type |
---|---|
event | string |
listener | (code : number | null ) => void |
Returns
void
stderr
stderr: object;
stderr.on()
on: (event: string, listener: (chunk: any) => void) => void;
Parameters
Parameter | Type |
---|---|
event | string |
listener | (chunk : any ) => void |
Returns
void
stdout
stdout: object;
stdout.on()
on: (event: string, listener: (chunk: any) => void) => void;
Parameters
Parameter | Type |
---|---|
event | string |
listener | (chunk : any ) => void |
Returns
void
See
handleRunCommand in app/electron/main.ts
This function uses the desktopApi.send and desktopApi.receive methods to communicate with the main process.
Example
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);
});