special sponsors
Array
lando.shell.get() ⇒ Gets running processes.
Kind: global function
Returns: Array
- An array of the currently running processes
Since: 3.0.0
Promise
lando.shell.sh(cmd, [opts]) ⇒ Runs a command.
This is an abstraction method that:
- Delegates to either node's native
spawn
orexec
methods. - Promisifies the calling of these function
- Handles
stdout
,stdin
andstderr
Kind: global function
Returns: Promise
- A promise with collected results if applicable.
See
Since: 3.0.0
Param | Type | Default | Description |
---|---|---|---|
cmd | Array | The command to run as elements in an array. | |
[opts] | Object | Options to help determine how the exec is run. | |
[opts.mode] | Boolean | 'exec' | The mode to run in |
[opts.detached] | Boolean | false | Whether we are running in detached mode or not (deprecated) |
[opts.cwd] | Boolean | process.cwd() | The directory to run the command from |
Example
// Run a command in collect mode
return lando.shell.sh(['ls', '-lsa', '/'], {mode: 'collect'})
// Catch and log any errors
.catch(err => {
lando.log.error(err);
})
// Print the collected results of the command
.then(results => {
console.log(results);
});
String
| null
lando.shell.which(cmd) ⇒ Returns the path of a specific command or binary.
Kind: global function
Returns: String
| null
- The path to the command or null.
Since: 3.0.0
Param | Type | Description |
---|---|---|
cmd | String | A command to search for. |
Example
// Determine the location of the 'docker' command
const which = lando.shell.which(DOCKER_EXECUTABLE);