# xecutor

> Shell command runner for Node.js

Latest version **0.2.3** (published 2024-07-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install xecutor
pnpm add xecutor
yarn add xecutor
bun add xecutor
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.3 |
| Published | 2024-07-12 |
| First published | 2018-09-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Vidar Eldøy |
| Maintainers | eldoy |

## Links

- npm: https://www.npmjs.com/package/xecutor
- Repository: https://github.com/eldoy/xecutor
- Homepage: https://github.com/eldoy/xecutor#readme
- Issues: https://github.com/eldoy/xecutor/issues
- npm.io page: https://npm.io/package/xecutor

## Dependencies (2)

- [farge](https://npm.io/package/farge.md) ^0.1.3
- [extras](https://npm.io/package/extras.md) ^0.13.3

## Recent versions

- 0.2.3 (latest) — 2024-07-12
- 0.2.2 — 2024-07-12
- 0.2.1 — 2024-07-12
- 0.2.0 — 2024-07-12
- 0.1.2 — 2024-07-12
- 0.1.1 — 2024-07-11
- 0.1.0 — 2024-07-11
- 0.0.1 — 2018-09-27

## README

# Shell command runner for Node.js

Easily run shell commands from within Node.js, both locally and remote.

### Installation
```
npm i xecutor
```

### Usage
```js
var xecutor = require('xecutor')

var terminal = new xecutor({
  // The host name. Leave blank to run commands locally (default).
  host: 'root@ecma',

  // The dir to start executing commands in.
  // Default is your current dir for local, and the home dir for remote.
  dir: '/root',

  // The limit of history items, default is 10 000.
  // Set to 0 or null to disable history
  history: 10_000
})

terminal.history    // Log of all commands
terminal.dir        // Last working directory
terminal.id         // The unique id of this terminal

var { $ } = terminal

// Run a command
var result = $(`ls -la`)

// Temporarily override dir
var result = $(`ls -la`, { dir: '/home' })

// Temporarily override host
var result = $(`ls -la`, { host: 'vidar@68.141.121.18' })

result.stdout      // stdout output
result.stderr      // stderr output
result.code        // exit code
result.dir         // the working directory
result.command     // the last command executed
result.executed    // the actual command including host and dir
result.text        // the text from stdout or stderr

// Change dir, commands will be executed here from now
// Path must be absolute
$.cd(`/users/eldoy`)

// Returns current working dir
$.pwd()

// Get the tmpdir
$.tmpdir()

// Change to tmpdir
$.cd($.tmpdir())
```

MIT Licensed. Enjoy!

Created by [Eldøy Projects](https://eldoy.com)

---
_Source: https://npm.io/package/xecutor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
