GitFakeFs
Emulate (a so far very small subset of) node.js' fs
module on top of
a local git repository. Point GitFakeFs at a git repository, and optionally
a branch/tag/commit, and it'll give you back an fs
implementation that gets its
data from the repo.
var GitFakeFs = fs = '/path/to/repo.git'; fs;
To expose the contents of a branch, tag, or commit, use the 'ref' option:
'/path/to/repo.git' ref: 'HEAD';'/path/to/repo.git' ref: 'branchName';'/path/to/repo.git' ref: 'tagName';'/path/to/repo.git' ref: 'commitId';
The staged contents:
'/path/to/repo.git' ref: 'HEAD' index: true;
For non-bare repositories you can use the contents of the working copy as fallback when a file or directory doesn't exist:
'/path/to/repo.git' ref: 'HEAD' fallBackToWorkingCopy: true;'/path/to/repo.git' ref: 'HEAD' index: true fallBackToWorkingCopy: true;
Finally, you can configure a GitFakeFs instance to only contain the files and directories that have changes in the index:
'/path/to/repo.git' ref: 'HEAD' changesInIndex: true;
Supported functions:
readdir
readFile
stat
lstat
realpath
Installation
Make sure you have node.js and npm installed, then run:
npm install gitfakefs
License
3-clause BSD license -- see the LICENSE
file for details.