(folderPath: string, basePath: string, content: IndexedContent[])
| 55 | } |
| 56 | |
| 57 | export async function recursiveFolderIndex(folderPath: string, basePath: string, content: IndexedContent[]): Promise<void> { |
| 58 | // List all sub-files (and folders) |
| 59 | const files = await readdir(folderPath); |
| 60 | // Run a promise on each file (and wait for all to finish) |
| 61 | for (const fileName of files) { |
| 62 | const filePath = path.join(folderPath, fileName); |
| 63 | const stats = await lstat(filePath); |
| 64 | const isDirectory = stats.isDirectory(); |
| 65 | // Is a folder, go deeper |
| 66 | if (isDirectory) { |
| 67 | await recursiveFolderIndex(filePath, basePath, content); |
| 68 | // Is a file, add to index |
| 69 | } else { |
| 70 | content.push({ |
| 71 | filePath: fixSlashes(path.relative(basePath, filePath)), // Only have one type of slashes |
| 72 | fileSize: stats.size, |
| 73 | }); |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | export async function getTagsFromStr(tagsStr: string, tagCategoriesStr: string): Promise<Tag[]> { |
| 79 | const allTags: Tag[] = []; |
no test coverage detected