(content, filePath)
| 233 | }); |
| 234 | } |
| 235 | function findReferences(content, filePath) { |
| 236 | const fileDir = path.dirname(filePath); |
| 237 | const patterns = [ |
| 238 | /['"`][^`'\"]*?([./\w-]+\.(?:js|css|png|jpg|jpeg|gif|svg|woff2?|ttf|eot))['"`]/g, |
| 239 | /url\(['"]?([./\w-]+(?:\.(?:png|jpg|jpeg|gif|svg|woff2?|ttf|eot))?)['"]?\)/gi, |
| 240 | /@import\s+['"]([^'\"]+\.css)['"];?/gi, |
| 241 | /(?:src|href)=['"](chrome-extension:\/\/[^/]+\/)?([^'"?#]+(?:\.(?:js|css|png|jpg|jpeg|gif|svg|woff2?|ttf|eot)))['"]/gi |
| 242 | ]; |
| 243 | patterns.forEach((pattern, index) => { |
| 244 | let match; |
| 245 | while ((match = pattern.exec(content)) !== null) { |
| 246 | let extractedPath = ''; |
| 247 | if (index === 3) { |
| 248 | extractedPath = match[2]; |
| 249 | } else { |
| 250 | extractedPath = match[1]; |
| 251 | } |
| 252 | if (!extractedPath || typeof extractedPath !== 'string') continue; |
| 253 | if (shouldExcludeFile(extractedPath)) continue; |
| 254 | let finalPathToAdd = ''; |
| 255 | const isChromeExt = index === 3 && match[1]; |
| 256 | if (isChromeExt || extractedPath.startsWith('/')) { |
| 257 | finalPathToAdd = extractedPath.startsWith('/') ? extractedPath.slice(1) : extractedPath; |
| 258 | } else { |
| 259 | const absolutePath = path.resolve(fileDir, extractedPath); |
| 260 | finalPathToAdd = path.relative(outputDir, absolutePath); |
| 261 | } |
| 262 | if (finalPathToAdd && !shouldExcludeFile(finalPathToAdd)) { |
| 263 | referencedFiles.add(finalPathToAdd.replace(/\\/g, '/')); |
| 264 | } |
| 265 | } |
| 266 | }); |
| 267 | } |
| 268 | function processManifest() { |
| 269 | const manifestPath = path.join(outputDir, 'manifest.json'); |
| 270 | if (fs.existsSync(manifestPath)) { |
no test coverage detected