# mdfs

> Markdown simple file system for Testing propose

Latest version **2.0.5** (published 2021-03-12) · GPL-3.0 license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.5 |
| Published | 2021-03-12 |
| First published | 2015-09-01 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 44.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | thr0w |
| Maintainers | thr0w |

## Links

- npm: https://www.npmjs.com/package/mdfs
- Repository: https://github.com/thr0w/mdfs
- Issues: https://github.com/thr0w/mdfs/issues
- npm.io page: https://npm.io/package/mdfs

## Recent versions

- 2.0.5 (latest) — 2021-03-12
- 2.0.4 — 2019-04-22
- 2.0.2 — 2018-09-21
- 2.0.1 — 2018-09-21
- 2.0.0 — 2018-09-21
- 1.1.13 — 2018-09-21
- 1.1.12 — 2018-09-21
- 1.1.11 — 2018-09-21
- 1.1.10 — 2018-09-21
- 1.1.9 — 2018-09-21
- 1.1.8 — 2018-09-21
- 1.1.7 — 2018-09-21
- 1.1.6 — 2018-09-21
- 1.1.5 — 2018-09-21
- 1.1.4 — 2015-12-25
- … 10 more at https://npm.io/package/mdfs/versions

## README

# mdfs
[![Build](https://travis-ci.org/teintinu/mdfs.svg?branch=master)](https://travis-ci.org/teintinu/mdfs) [![Coverage](https://img.shields.io/coveralls/teintinu/mdfs.svg)](https://coveralls.io/r/teintinu/mdfs?branch=master)

Markdown with (Virtual)FileSystem it's a simple way to write many files with a single file, usefull for testcases, specially for transpilers. The main advantage of markdown it's sintax formatting for multiple languages, for example.

```

## file.html
՝՝՝html
<div>text</div>
՝՝՝

## file.jade
՝՝՝jade
div text
՝՝՝

## file.js
՝՝՝javascript
var e=document.createElement('div');
e.textContent = 'text';
՝՝՝

```


# install:
```bash
$ npm install mdfs
```
# usage:
```javascript
var mdfs = require('mdfs')
```

# api:
## mdfs.parse
> parses an md file in a pure javascript object with each virtual file is mapped to a file
```javascript
var mdfs=require('mdfs');
var test=mdfs.parse(mdcontent);
```
This code will return
```javascript
test = {
  'file.html': '<div>text</div>'
  'file.jade': 'div\n  text'
  'file.js': "var e=document.createElement('div');\ne.textContent = 'text';"
```

## mdfs.search 
> searchs *.md files in a directory, parses each one and invoke a callback with parsed object for each one.
```javascript
var mdfs=require('mdfs');
declare('My transpiler test', function(){
  mdfs.search('tests/cases', function callback_function(test){
    if (test.pending)
      xit(test.title);
    else {
      var it_fn = test.only ? it.only : it;
      it_fn(test.title, function(done){
         var actual = my_transpile_function(test.jade);
         var expected = test.html;
         expect(actual).to.be.equal(expected);
      });
    }
  });
});
```
This code will:
* Search all md files (*.md) in tests/cases folder
* Parse each one 
* Invoke callback_function for each parsed file. The callback parameter contains parsed file return plus mdfs attribute.
> test parameter of search callback has refresh method
 
##### mdfs attributes:
* fullname: name of parsed file
* title: the first header on file
* only: true if exists an `**only**` line 
* skip: true if exists an `**skip**` line 
* pending: true if exists an `**pending**` line 

## mdfs.describe
> create tests (describe/it/xit) for each *.md file on `dirname` and subfolders invoking the callback for make some transformation and return actual value witch will be compared with expected value on .md file. A second callback can be used to define to test title and the third callback can be used to compare actual and expected values.
```javascript
var mdfs = require('mdfs')
mdfs.describe(dirname, 'EXPECTED_FILE_NAME',
  function transform_callback(test) {
    var ACTUAL = TRANSFORM_FUNCTION(test['SOURCE_FILE_NAME']);
    return ACTUAL
  }
)
```
This code will create (bdd style) tests that invoke transform_callback function for each file. The special file name `throw` can be used for transformation failures.
See `test/sample.js` for a ES6 to ES5 transpile with using Babel.

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