Package Exports
- fixturify
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fixturify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
node-fixturify
Convert JSON objects into directory structures in the file system, and back again. Primarily useful when writing tests.
Installation
npm install --save-dev fixturify
Usage
var fixturify = require('fixturify')
fs.mkdirSync('testdir')
var obj = {
'foo.txt': 'foo.txt contents',
'subdir': {
'bar.txt': 'bar.txt contents',
'symlink': ['../foo.txt']
}
}
fixturify.writeSync('testdir', obj) // write it to disk
fixturify.readSync('testdir') // => deep-equals obj
File contents are decoded and encoded with UTF-8.
Symlinks are represented as arrays of length 1. It does not matter whether the symlink target exists.
Limitations
To keep the API simple, node-fixturify has the following limitations:
Reading or setting file stats (last-modified time, permissions, etc.) is not supported.
Special files like FIFOs, sockets, or devices are not supported.
File contents are automatically encoded/decoded into strings. Binary files are not supported.
Symlinks are represented as arrays of length 1. We do this because symlinks are important to support, and arrays, though ugly, are an easy way to implement them.