1.1.0 • Published 8 years ago
fx45-node v1.1.0
fx45-node
Generate JSON files for fx54-node.
The packages names may be slightly confusing:
fx54-nodeVerify the existence or content of files in a hierarchical object.fx45-nodeGenerate JSON files for fx54-node.
Installation
yarn add fx45-nodeRun tests
yarn testExample
Assume a directory with following structure:
- root
- dir1
a.txt
- dir2
b.txtCode:
import objectFromDirectory from 'fx45-node';
// or Node.js style: const objectFromDirectory = require('fx45-node').default;
console.log(JSON.stringify(objectFromDirectory('./root')));Output:
{
"dir1": {
"a.txt": "Contents of a.txt"
},
"dir2": {
"b.txt": "Contents of b.txt"
}
}API
import objectFromDirectory from 'fx45-node';
objectFromDirectory(directory: string, ignoredFiles: string[]|null = null): object|nullignoredFilesfiles to be ignored, e.g.['.DS_Store', 'thumbs.db'].