# promise-exec

> make child_process.exec return promise

Latest version **0.1.0** (published 2015-06-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install promise-exec
pnpm add promise-exec
yarn add promise-exec
bun add promise-exec
```

## 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.1.0 |
| Published | 2015-06-13 |
| First published | 2015-06-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | luckydrq |
| Maintainers | luckydrq |
| Keywords | exec, promise, child_process |

## Links

- npm: https://www.npmjs.com/package/promise-exec
- Repository: https://github.com/luckydrq/promise-exec
- Homepage: https://github.com/luckydrq/promise-exec#readme
- Issues: https://github.com/luckydrq/promise-exec/issues
- npm.io page: https://npm.io/package/promise-exec

## Dependencies (3)

- [mz](https://npm.io/package/mz.md) ^2.0.0
- [thenify](https://npm.io/package/thenify.md) ^3.1.0
- [native-or-bluebird](https://npm.io/package/native-or-bluebird.md) ^1.2.0

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 0.1.0 (latest) — 2015-06-13

## README

# promise-exec
A simple wrap for child_process.exec which returns promise

## Installation

```bash
$ npm install promise-exec
```

## API

### exec

It's a promise version of `child_process.exec`.

```javascript
var exec = require('promise-exec');

exec('ls -al')
  .then(function(result) {
    console.log(result);
  })
  .catch(function(err) {
    console.error(err);
  });
```

### exports.wrap

It's a sugar for subsequent thenable calls that makes code simpler and more elegant.

```javascript
var exec = require('promise-exec').wrap;

Promise.resolve()
  .then(exec('git add .'))
  .then(exec('git commit -m "fix xxx"'))
  .then(exec('git push origin master'))
  .catch(function(err) {
    console.error(err);
  });
```

### exports.execFile

Promise version of executing a shell script file, just like `sh test.sh`.

test.sh:

```bash
touch index.txt
echo "hello" > index.txt
# comments will be ingored
cat index.txt
```

index.js:

```javascript
var fs = require('fs');
var path = require('path');
var execFile = require('promise-exec').execFile;
var file = path.join(__dirname, './test.sh');

execFile(file)
  .then(function() {
    var txt = path.join(__dirname, 'index.txt');
    console.log(fs.existsSync(txt));  // true

    var content = fs.readFileSync(txt, { encoding: 'utf8' });
    console.log(content);  // hello\n
  })
  .catch(function(err) {
    console.error(err);
  });
```

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