Simple in-memory vinyl file store.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Simple in-memory vinyl file store.


Loading a file

You access a file using store#get() method. If the file is in memory, it will be used. Otherwise, we'll load the file from the file-system.

var store = require('mem-fs').create();


When trying to load a file we cannot read from disk, an empty Vinyl file will be returned. The contents of this file will be set to null.

Trying to get a directory or any invalid files will also return an empty Vinyl file pointer.

Adding/updating a file

You update file references by using store#add() method. This method take a vinyl file object as parameter.

var File = require('vinyl');
var store = require('mem-fs').create();

var coffeeFile = new File({
  cwd: '/',
  base: '/test/',
  path: '/test/',
  contents: new Buffer('test = 123')


Iterating over the file system

Using store#each(cb(file, index)), you can iterate over every file stored in the file system.