# acquit-require

> Pull examples from your test files into markdown or HTML

Latest version **0.1.1** (published 2018-06-11) · Apache 2.0 license · 0 weekly downloads

## Install

```sh
npm install acquit-require
pnpm add acquit-require
yarn add acquit-require
bun add acquit-require
```

Provides the command `acquit-require`.

## 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.1 |
| Published | 2018-06-11 |
| First published | 2018-05-03 |
| Weekly downloads | 0 |
| License | Apache 2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 18.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Valeri Karpov |
| Maintainers | vkarpov15 |

## Links

- npm: https://www.npmjs.com/package/acquit-require
- Repository: https://github.com/vkarpov15/acquit-require
- Homepage: https://github.com/vkarpov15/acquit-require#readme
- Issues: https://github.com/vkarpov15/acquit-require/issues
- npm.io page: https://npm.io/package/acquit-require

## Dependencies (1)

- [commander](https://npm.io/package/commander.md) 2.15.1

## Recent versions

- 0.1.1 (latest) — 2018-06-11
- 0.1.0 — 2018-05-31
- 0.0.4 — 2018-05-25
- 0.0.3 — 2018-05-25
- 0.0.2 — 2018-05-03

## README

# acquit-require

Utility to pull mocha tests into markdown, HTML, etc.


# transform()


This is the function you want to use. Given a string
(markdown, HTML, Jade, etc.) and the raw source code of some mocha tests,
this function returns a string with `[require:bar]` replaced with the
source code of the first test that matches the regexp 'bar'.

Given the below markdown `article`:

    Printing "Hello, World" in JavaScript is easy:
    
    ```
    [require:bar]
    ```
    
    This is how you print "Bye!" instead:
    
    ```
    [require:baz]
    ```
    

And the below mocha test `code`:

```javascript
describe('foo', function() {
  it('bar', function() {
    console.log('Hello, World!');
  });

  it('baz', function() {
    console.log('Bye!');
  });
});

```

The `transform()` function will pull the source code of the two tests into
your markdown file.


```javascript

  const output = transform(article, code);

  const logStatements = output.match(/console\.log(.*);/g);

  assert.ok(logStatements);
  assert.equal(logStatements[0].trim(), `console.log('Hello, World!');`);
  assert.equal(logStatements[1].trim(), `console.log('Bye!');`);

```

# findTest()

```javascript

  assert.equal(findTest('foo', code).trim(),
    `console.log('Hello, World!');`);
  assert.equal(findTest('bar', code).trim(),
    `console.log('Hello, World!');`);
  assert.equal(findTest('foo bar', code).trim(),
    `console.log('Hello, World!');`);
  assert.equal(findTest('baz', code).trim(),
    `console.log('Bye!');`);
  assert.ok(!findTest('bar baz', code));

```

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