| 37 | type relFile = {name: string; fullPath: string}; |
| 38 | |
| 39 | function getAllFiles(root: string, dir?: string): Array<relFile> { |
| 40 | const actualDir = dir || root; |
| 41 | return fs.readdirSync(actualDir).reduce((files: Array<relFile>, file: string) => { |
| 42 | const fullPath = path.join(actualDir, file); |
| 43 | const name = path.relative(root, fullPath); |
| 44 | const isDirectory = fs.statSync(fullPath).isDirectory(); |
| 45 | return isDirectory ? [...files, ...getAllFiles(root, fullPath)] : [...files, {name, fullPath}]; |
| 46 | }, []); |
| 47 | } |
| 48 | |
| 49 | type CacheEntry = {path: string; size: number}; |
| 50 | |