Create a filesystem tree from a definition. This module is intended to use in unit/e2e tests to create a pre-determined fs trees.
You probably want to install this as an npm dev dependency:
npm install --save-dev create-fs-tree
Use it in your tests:
Creates under the
root directory a fs tree as specified in the
rootdirectory before creating the specified fs tree.
rootstring: root directory under which the fs tree is created. The directory is created if it doesn't exist, it's emptied if it already exists
definitionobject: an object describing the fs tree to create. Its properties' values can either be:
- strings or buffers: in which case a file with the property key as name and the property value as content will be created
- definition objects: in which case a directory with the property key as name will be created, and under it a fs tree as described by the property value (which of course is a definition object)
Creates a fs tree so that:
$ tree mydirmydir├── level-0-file└── level-0-dir├── level-1-file└── level-1-dir$ cat mydir/level-0-filelevel-0-file content$ cat mydir/level-0-dir/level-1-filelevel-1-file content
root path. Equivalent to
rootstring: path to remove