| 42 | export const md5 = (content: string) => encrypt('md5', content); |
| 43 | |
| 44 | export function folderSize(folderPath: string) { |
| 45 | let size = 0; |
| 46 | const _next = function a(p: string) { |
| 47 | if (p) { |
| 48 | const stats = fs.statSync(p); |
| 49 | if (!stats.isDirectory() || stats.isSymbolicLink()) { |
| 50 | if (!stats.isSymbolicLink()) size += stats.size; |
| 51 | } else { |
| 52 | size += stats.size; |
| 53 | const files = fs.readdirSync(p); |
| 54 | if (Array.isArray(files)) { |
| 55 | for (const file of files) _next(path.join(p, file)); |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | }; |
| 60 | _next(folderPath); |
| 61 | return size; |
| 62 | } |
| 63 | |
| 64 | String.prototype.format = function formatStr(...args) { |
| 65 | let result = this; |