feat: walk al pack directories

master
ogomez-at-wiris 2022-02-20 15:48:03 +01:00
parent 9ffb67ddff
commit 0beeb75cf0
1 changed files with 32 additions and 1 deletions

View File

@ -11,6 +11,37 @@ export default class PackService {
public static getInitialList = async () => { public static getInitialList = async () => {
const packs = await fs.readdirSync(PACK_BASE_PATH); const packs = await fs.readdirSync(PACK_BASE_PATH);
packs.forEach((pack) => {});
// Setup walk
const noDots = (entry: fsWalk.Entry) => !entry.path.startsWith(".");
packs.forEach(async (pack) => {
const name = pack;
let size = 0;
let bpm: string = "";
const packFiles = await fsWalk.walkSync(`${PACK_BASE_PATH}/${pack}`, {
entryFilter: noDots,
concurrency: 4,
});
packFiles.forEach(async (file) => {
size += await fs.statSync(file.path).size;
if (file.name === "bpm.txt") {
bpm = await fs.readFileSync(file.path).toString();
}
});
const currentPack: Pack = {
name: name,
size: size,
bpm: bpm,
};
console.log(currentPack);
if (currentPack.bpm !== '') {
PackService.packList.push(currentPack);
} else {
console.log('found corrupted pack', currentPack.name)
}
});
}; };
} }