# fs-tree

> Builds hierarchies of directories and files

Latest version **1.0.0** (published 2015-09-11) · BSD license · 0 weekly downloads

## Install

```sh
npm install fs-tree
pnpm add fs-tree
yarn add fs-tree
bun add fs-tree
```

## 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.0 |
| Published | 2015-09-11 |
| First published | 2013-12-01 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Josh Chisholm |
| Maintainers | joshski, refractalize |

## Links

- npm: https://www.npmjs.com/package/fs-tree
- Repository: https://github.com/featurist/fs-tree
- Issues: https://github.com/featurist/fs-tree/issues
- npm.io page: https://npm.io/package/fs-tree

## Dependencies (2)

- [mkdirp](https://npm.io/package/mkdirp.md) ~0.5.0
- [rimraf](https://npm.io/package/rimraf.md) ~2.2.8

## Recent versions

- 1.0.0 (latest) — 2015-09-11
- 0.2.0 — 2015-04-21
- 0.1.0 — 2014-09-26
- 0.0.1 — 2013-12-01

## README

# fs-tree

Builds a hierarchy of directories and files as a single asynchronous operation.

### Install

    npm install fs-tree

### Usage

    fsTree = require 'fs-tree'

    fsTree! {
      ideas = {
        colours = {
          "green.txt" = "apples, pears"
          "white.txt" = "snow"
        }
      }
    }

...creates these directories and files:

    ./ideas/
    ./ideas/colours/
    ./ideas/colours/green.txt  (apples, pears)
    ./ideas/colours/white.txt  (snow)

Each entry can be a string, a `Buffer` or a node stream (anything that has a `.pipe()` method).

### The root directory

By default the hierarchy is created in the current working directory.

Make a hierarchy under another directory like this:

    fsTree! '/your/root/directory' {
      subdir = {
        file = "contents"
      }
    }

### Deleting the files you created

Retain a reference to the original tree to destroy it later:

    tree = fsTree! {
      subdir = {
        file = "contents"
      }
    }

    // then later...
    tree.destroy()!

Destroying the tree is equivalent to

    rm -rf <root directory>

### JavaScript?

The examples above are in [PogoScript](http://pogoscript.org) because it's pretty. There is no dependency on PogoScript, so you can use pure JavaScript if you prefer. It returns a promise:

    var fsTree = require('fs-tree');

    fsTree({
      ideas: {
        colours: {
          "green.txt": "apples, pears",
          "white.txt": "snow"
        }
      }
    }).then(function() {
      console.log("Tree created!");
    }, function (error) {
      console.log("uh oh", error);
    });

### License

BSD

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