# view-fs

> View plugin for `templates` that adds methods for working with the file system. Works with assemble, verb, and any other `templates` based applications

Latest version **0.2.0** (published 2016-05-12) · MIT license · 0 weekly downloads

## Install

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

## 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.2.0 |
| Published | 2016-05-12 |
| First published | 2016-03-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert |
| Keywords | assemble, copy, del, delete, file, fs, move, path, plugin, read, templates, verb, vinyl, write |

## Links

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

## Dependencies (6)

- [debug](https://npm.io/package/debug.md) ^2.2.0
- [write](https://npm.io/package/write.md) ^0.3.1
- [delete](https://npm.io/package/delete.md) ^0.3.2
- [read-file](https://npm.io/package/read-file.md) ^0.2.0
- [lazy-cache](https://npm.io/package/lazy-cache.md) ^2.0.1
- [extend-shallow](https://npm.io/package/extend-shallow.md) ^2.0.1

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.2.0 (latest) — 2016-05-12
- 0.1.1 — 2016-03-09
- 0.1.0 — 2016-03-09

## README

# view-fs [![NPM version](https://img.shields.io/npm/v/view-fs.svg?style=flat)](https://www.npmjs.com/package/view-fs) [![NPM downloads](https://img.shields.io/npm/dm/view-fs.svg?style=flat)](https://npmjs.org/package/view-fs) [![Build Status](https://img.shields.io/travis/jonschlinkert/view-fs.svg?style=flat)](https://travis-ci.org/jonschlinkert/view-fs)

View plugin for `templates` that adds methods for working with the file system. Works with assemble, verb, and any other `templates` based applications

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install view-fs --save
```

## Usage

```js
var templates = require('templates');
var viewFs = require('view-fs');

var app = templates();
app.use(viewFs());
```

## API

### [.read](index.js#L37)

Read `file.path` and update `file.contents` with the result.

**Params**

* `options` **{Object}**: Options to pass to `  fs.readFile` and/or define `options.forceRead` to read from the file system, even when `file.contents` is already populated.
* `cb` **{Function}**

**Example**

```js
app.view('foo.txt')
  .read(function(err, file) {
     console.log(file.contents);
  });
```

### [.write](index.js#L91)

Asynchronously writes `file.contents` to the given `dest` path on the file system, replacing the file if it already exists.

**Params**

* `dest` **{String}**: Desination directory
* `options` **{Object}**
* `cb` **{Function}**

**Events**

* `emits`: write

**Example**

```js
app.view('foo.txt', {content: 'this is content...'})
  .write('dist/', function(err, view) {
     // writes to `dist/foo.txt`
  });
```

### [.del](index.js#L140)

Asynchronously deletes `file.path` from the file system.

**Params**

* `options` **{Object}**
* `cb` **{Function}**

**Events**

* `emits`: del

**Example**

```js
app.view('foo.txt', {content: 'this is content...'})
  .del(function(err) {
    if (err) throw err;
  });
```

### [.move](index.js#L173)

Asynchronously writes `file.contents` to the given `dest` directory, and deletes the source file at `file.path`.

**Params**

* `dest` **{String}**: Desination directory
* `options` **{Object}**
* `cb` **{Function}**

**Events**

* `emits`: move

**Example**

```js
app.view('foo.txt', {content: 'this is content...'})
  .move('dist/', function(err) {
    if (err) throw err;
    // writes `dist/foo.txt` and deletes `foo.txt`
  });
```

## Related projects

You might also be interested in these projects:

* [delete](https://www.npmjs.com/package/delete): Delete files and folders and any intermediate directories if they exist (sync and async). | [homepage](https://github.com/jonschlinkert/delete)
* [read-file](https://www.npmjs.com/package/read-file): Thin wrapper around fs.readFile and fs.readFileSync that also strips byte order marks when `utf8` encoding… [more](https://www.npmjs.com/package/read-file) | [homepage](https://github.com/jonschlinkert/read-file)
* [write](https://www.npmjs.com/package/write): Write files to disk, creating intermediate directories if they don't exist. | [homepage](https://github.com/jonschlinkert/write)

## Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/view-fs/issues/new).

## Building docs

Generate readme and API documentation with [verb](https://github.com/verbose/verb):

```sh
$ npm install verb && npm run docs
```

Or, if [verb](https://github.com/verbose/verb) is installed globally:

```sh
$ verb
```

## Running tests

Install dev dependencies:

```sh
$ npm install -d && npm test
```

## Author

**Jon Schlinkert**

* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)

## License

Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/jonschlinkert/view-fs/blob/master/LICENSE).

***

_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on May 12, 2016._

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