# @pawelgalazka/shell

> Simple exec of shell commands

Latest version **2.0.0** (published 2019-04-24) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @pawelgalazka/shell
pnpm add @pawelgalazka/shell
yarn add @pawelgalazka/shell
bun add @pawelgalazka/shell
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-04-24 |
| First published | 2019-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8.6.0 |
| Dependencies | 0 |
| Unpacked size | 221.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Paweł Gałązka |
| Maintainers | pawelgalazka |
| Keywords | shell, bash, exec, spawn |

## Links

- npm: https://www.npmjs.com/package/@pawelgalazka/shell
- Repository: https://github.com/pawelgalazka/shell
- Homepage: https://github.com/pawelgalazka/shell#readme
- Issues: https://github.com/pawelgalazka/shell/issues
- npm.io page: https://npm.io/package/@pawelgalazka/shell

## Recent versions

- 2.0.0 (latest) — 2019-04-24
- 1.0.0 — 2019-02-09

## README

# shell ![node version](https://img.shields.io/node/v/%40pawelgalazka%2Fshell.svg) [![Build Status](https://travis-ci.org/pawelgalazka/shell.svg?branch=master)](https://travis-ci.org/pawelgalazka/shell) [![npm version](https://badge.fury.io/js/%40pawelgalazka%2Fshell.svg)](https://badge.fury.io/js/%40pawelgalazka%2Fshell)
Simple exec of shell commands in node

``` js
const { shell } = require('@pawelgalazka/shell')

shell('touch somefile.js')
shell('http-server', { async: true })
```


## shell(cmd, options)

*Options:*

```javascript
{
    cwd: ..., // current working directory (String)
    async: ... // run command asynchronously (true/false), false by default
    env: ... // environment key-value pairs (Object)
    timeout: ...
    transform: // function which transforms the output, line by line
    nopipe: // if true, it will send output directly to parent process
    silent: // if true, it won't print anything to the terminal
}
```

```ts
interface IShellOptions {
  cwd?: string
  env?: NodeJS.ProcessEnv
  timeout?: number
  async?: boolean
  nopipe?: boolean
  silent?: boolean
  transform?: (output: string) => string
}
```

## prefixTransform(prefix)

Transform function which can be used for `transform` option.

*Example:*

```js
const { shell, prefixTransform } = require('@pawelgalazka/shell')

shell('echo "test"', { transform: prefixTransform('[prefix]') })
```

```sh
$ node ./script.js
echo "test"
[prefix] test
```

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