Convert the contents of a directory to an object.
npm i node-dir-to-obj
Suppose a directory structure like this:
a.txt
subDir
-- b.txt
import dirToObj from 'node-dir-to-obj';
const obj = await dirToObj('<dir path>');
/*
{
'a.txt': '<contents of a.txt>',
sub: {
'b.txt': '<contents of a.txt>',
},
}
*/
-
ignoreMap
a set of names that should be ignored. -
textMode
dumps file contents as text instead of hex.