(options: {
directory: string;
pattern?: string | RegExp;
budget?: number;
})
| 125 | } |
| 126 | |
| 127 | export function fileSizeIssues(options: { |
| 128 | directory: string; |
| 129 | pattern?: string | RegExp; |
| 130 | budget?: number; |
| 131 | }): Promise<Issue[]> { |
| 132 | const { directory, pattern, budget } = options; |
| 133 | |
| 134 | return crawlFileSystem({ |
| 135 | directory, |
| 136 | pattern, |
| 137 | fileTransform: async (file: string) => { |
| 138 | // get size of file |
| 139 | // const filePath = path.join(directory, file); |
| 140 | const stats = await stat(file); |
| 141 | |
| 142 | return assertFileSize(file, stats.size, budget); |
| 143 | }, |
| 144 | }); |
| 145 | } |
| 146 | |
| 147 | export function infoMessage(filePath: string, size: number) { |
| 148 | return `File ${path.basename(filePath)} is OK. (size: ${formatBytes(size)})`; |
no test coverage detected