(
dirPath: string,
baseDir: string = dirPath,
fileList: Record<string, FileWithPermissions> = {},
additionalPatterns: string[] = [],
ignoredCount = 0,
)
| 118 | } |
| 119 | |
| 120 | export function getAllFilesWithCount( |
| 121 | dirPath: string, |
| 122 | baseDir: string = dirPath, |
| 123 | fileList: Record<string, FileWithPermissions> = {}, |
| 124 | additionalPatterns: string[] = [], |
| 125 | ignoredCount = 0, |
| 126 | ): GetAllFilesResult { |
| 127 | const files = readdirSync(dirPath); |
| 128 | |
| 129 | const ignoreChecker = buildIgnoreChecker(additionalPatterns); |
| 130 | |
| 131 | for (const file of files) { |
| 132 | const filePath = join(dirPath, file); |
| 133 | const relativePath = relative(baseDir, filePath); |
| 134 | |
| 135 | if (ignoreChecker.ignores(relativePath)) { |
| 136 | ignoredCount++; |
| 137 | continue; |
| 138 | } |
| 139 | |
| 140 | const stat = statSync(filePath); |
| 141 | |
| 142 | if (stat.isDirectory()) { |
| 143 | const result = getAllFilesWithCount( |
| 144 | filePath, |
| 145 | baseDir, |
| 146 | fileList, |
| 147 | additionalPatterns, |
| 148 | ignoredCount, |
| 149 | ); |
| 150 | ignoredCount = result.ignoredCount; |
| 151 | } else { |
| 152 | // Use forward slashes in zip file paths |
| 153 | const zipPath = relativePath.split(sep).join("/"); |
| 154 | fileList[zipPath] = { |
| 155 | data: readFileSync(filePath), |
| 156 | mode: stat.mode, |
| 157 | }; |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | return { files: fileList, ignoredCount }; |
| 162 | } |
no test coverage detected
searching dependent graphs…