(contentPath: string, log: (content: string) => void)
| 37 | * @param log Log function to use for errors |
| 38 | */ |
| 39 | export async function indexContentFolder(contentPath: string, log: (content: string) => void): Promise<IndexedContent[]> { |
| 40 | const content: IndexedContent[] = []; |
| 41 | await access(contentPath, fs.constants.F_OK) |
| 42 | .then(() => { |
| 43 | return recursiveFolderIndex(contentPath, contentPath, content) |
| 44 | .catch((error) => { |
| 45 | log('Error indexing folder - ' + error.message); |
| 46 | console.error(error); |
| 47 | }); |
| 48 | }) |
| 49 | .catch(() => { |
| 50 | const msg = `Content folder given doesn't exist, skipping... (${contentPath})`; |
| 51 | log(msg); |
| 52 | console.log(msg); |
| 53 | }); |
| 54 | return content; |
| 55 | } |
| 56 | |
| 57 | export async function recursiveFolderIndex(folderPath: string, basePath: string, content: IndexedContent[]): Promise<void> { |
| 58 | // List all sub-files (and folders) |
nothing calls this directly
no test coverage detected