# answer-prompt

> Answer prompts written to stderr or stdout.

Latest version **1.0.1** (published 2016-02-09) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install answer-prompt
pnpm add answer-prompt
yarn add answer-prompt
bun add answer-prompt
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-02-09 |
| First published | 2015-11-04 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Matthew Phillips |
| Maintainers | matthewp |
| Keywords | prompt, stdin, suppose |

## Links

- npm: https://www.npmjs.com/package/answer-prompt
- Repository: https://github.com/matthewp/answer-prompt
- Homepage: https://github.com/matthewp/answer-prompt#readme
- Issues: https://github.com/matthewp/answer-prompt/issues
- npm.io page: https://npm.io/package/answer-prompt

## Dependencies (1)

- [stream-when](https://npm.io/package/stream-when.md) ^1.0.0

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-02-09
- 1.0.0 — 2015-11-04

## README

[![Build Status](https://travis-ci.org/matthewp/answer-prompt.svg?branch=master)](https://travis-ci.org/matthewp/answer-prompt)
[![npm version](https://badge.fury.io/js/answer-prompt.svg)](http://badge.fury.io/js/answer-prompt)

# answer-prompt

Answer prompt questions for easier scripting and test automation.

## Install

```
npm install answer-prompt --save
```

## Usage

Create a [child process](https://nodejs.org/api/child_process.html) any way you which and pass it into answerPrompt. This will return a function that can be called to to answer questions.

```js
var spawn = require("child_process").spawn;
var answerPrompt = require("answer-prompt");

var child = spawn("some_script.js");
var answer = answerPrompt(child, "stdout"); // 'stderr' also accepted

answer(/first name/, "Matthew\n");
answer(function(str){
  return str.trim() === "last name";
}, "Phillips\n");
```

### answer(tester, response)

**tester** can be either a Function, a RegExp (probably most useful) or a String. answerPrompt will listen to stdout (default) or stderr and when a test passes write the **response** to stdin.

## License

BSD 2 Clause

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