Commit a800891b authored by Ruben Seggers's avatar Ruben Seggers
Browse files

add check if directories and json names match, fixed schema where that wasn't the case

parent d1cf8776
Showing with 3 additions and 0 deletions
+3 -0
......@@ -22,6 +22,9 @@ async function getHierarchy(dir, hierarchy, rootDir, hierarchyType) {
hierarchy[path2dir(filePath, hierarchyType)]['children'].push(dirent.name);
await getHierarchy(path.resolve(dir, dirent.name), hierarchy, rootDir, hierarchyType);
} else if (dirent.name.split('.')[1] === 'json') {
if (dir.split('/').splice(-1)[0] !== dirent.name.split('.')[0] && filePath !== '') {
console.log(`E: Directory '${dir.split('/').splice(-1)[0]}' and json name '${dirent.name}' do not match`);
}
let data = fs.readFileSync(`${dir}/${dirent.name}`);
hierarchy[path2dir(filePath, hierarchyType)] = {...hierarchy[path2dir(filePath, hierarchyType)], ...JSON.parse(data)};
hierarchy[path2dir(filePath, hierarchyType)]['path'] = hierarchyType + filePath || hierarchyType;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment