Cascading filesystem for node.js
Last updated a year ago by lilleman .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install larvitfs 
SYNC missed versions from official npm registry.

Build Status Dependencies Coverage Status


Get a local file from a "virtual" hierarchy, merged filesystem inspired by the Kohana Framework Cascading Filesystem.

The whole module is synchronous to work well with various template engines and other stuff. Since it returnes the resolved files from a local cache, this should normally not be a problem. However, if this module is used for thousands and thousands of files with different filenames this will have an performance impact.


npm i larvitfs


Load module

Paths are relative to process.cwd() as first priority. If nothing is found there, all modules will be tested as relative to this path to try to find a matching file. The modules are searched in the order given in package.json dependencies.


const LUtils = require('larvitutils'),
      Lfs    = require('larvitfs'),
      lfs    = new Lfs({
        'basePath':     process.cwd(),            // OPTIONAL
        'cacheMaxSize': 10000,                    // OPTIONAL
        'log':          new (new LUtils()).Log(), // OPTIONAL
        'fs':           require('fs')             // OPTIONAL

ES6 modules

import Lfs from 'larvitfs';
const lfs = new Lfs({}); // And of course with all the options as above


The idea here is to be able to share files between modules and application in a transparant way.

Lets say you'd wish to serve a HTML file, index.html. The default file resides in our little module "foobar" like this:


If we run getPathSync('public/index.html'); we'll get the full path back:

const Lfs = require('larvitfs'),
      lfs = new Lfs();

// /app/absolute/path/node_modules/foobar/public/index.html

But if we add this file to our own application, in ./public/index.html, that file will be higher in priority and will be returned instead:

const Lfs = require('larvitfs'),
      lfs = new Lfs();

// /app/absolute/path/public/index.html

All modules in node_modules will be searched for the given file. The priority is decided by the list order in dependencies in package.json.


The idea with this function is to be able to get a list of paths sorted in the dependency order. First local paths, then dependency paths and then everything else.

const Lfs = require('larvitfs'),
      lfs = new Lfs();

// [
//	'/app/absolute/path/public/index.html',
//	'/app/absolute/path/node_modules/directDependency/public/index.html',
//	'/app/absolute/path/node_modules/indirectDependency/public/index.html'

Current Tags

  • 2.3.1                                ...           latest (a year ago)

10 Versions

  • 2.3.1                                ...           a year ago
  • 2.3.0                                ...           a year ago
  • 2.2.0                                ...           a year ago
  • 2.0.4                                ...           2 years ago
  • 2.0.3                                ...           2 years ago
  • 2.0.2                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           4 years ago
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (7)

Copyright 2014 - 2016 © |