Modules@robinpath/shell

@robinpath/shell

0.1.0Public

Execute shell commands, inspect the process environment, and query system information

@robinpath/shell

Execute shell commands, inspect the process environment, and query system information

Category Functions Auth License

Why use this module?

The shell module lets you:

  • Execute a command string in the system shell and return stdout, stderr, and exitCode
  • Execute a command string in the system shell and return trimmed stdout. Throws on non-zero exit
  • Execute a file directly without a shell and return stdout, stderr, and exitCode
  • Find the full path of a command using which (or where on Windows)
  • Get a copy of all current environment variables

All functions are callable directly from RobinPath scripts with a simple, consistent API.

Installation

npm install @robinpath/shell

Quick Start

No credentials needed — start using it right away:

shell.run "echo hello"

Available Functions

FunctionDescription
shell.execExecute a command string in the system shell and return stdout, stderr, and exitCode
shell.runExecute a command string in the system shell and return trimmed stdout. Throws on non-zero exit
shell.execFileExecute a file directly without a shell and return stdout, stderr, and exitCode
shell.whichFind the full path of a command using which (or where on Windows)
shell.envGet a copy of all current environment variables
shell.cwdGet the current working directory
shell.exitExit the current process with a given exit code
shell.pidGet the process ID of the current process
shell.platformGet the operating system platform identifier
shell.uptimeGet the number of seconds the current process has been running

Examples

Execute a command string in the system shell and return trimmed stdout. Throws on non-zero exit

shell.run "echo hello"

Execute a file directly without a shell and return stdout, stderr, and exitCode

shell.execFile "/usr/bin/node" ["--version"]

Find the full path of a command using which (or where on Windows)

shell.which "node"

Integration with RobinPath

import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/shell";

const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);

const result = await rp.executeScript(`
  shell.run "echo hello"
`);

Full API Reference

See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.

Related Modules

License

MIT

Versions (1)

VersionTagPublished
0.1.0latestyesterday
Install
$ robinpath install @robinpath/shell
Version0.1.0
LicenseMIT
Unpacked Size4.1 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

Category

utilities