(opts)
| 41 | main(program.opts(), program.args) |
| 42 | |
| 43 | async function main(opts) { |
| 44 | const { json, verbose, exit, excludeTranslations } = opts |
| 45 | |
| 46 | const walkOptions = { |
| 47 | directories: false, |
| 48 | includeBasePath: true, |
| 49 | } |
| 50 | const sourceFiles = [] |
| 51 | const roots = [ |
| 52 | 'content', |
| 53 | 'data', |
| 54 | 'tests', |
| 55 | 'components', |
| 56 | 'script', |
| 57 | 'stylesheets', |
| 58 | 'contributing', |
| 59 | 'pages', |
| 60 | '.github/actions-scripts', |
| 61 | ] |
| 62 | if (!excludeTranslations) { |
| 63 | roots.push('translations') |
| 64 | } |
| 65 | |
| 66 | for (const root of roots) { |
| 67 | sourceFiles.push( |
| 68 | ...walk( |
| 69 | root, |
| 70 | Object.assign( |
| 71 | { |
| 72 | globs: ['!**/*.+(png|jpe?g|csv|graphql|json|svg)'], |
| 73 | }, |
| 74 | walkOptions |
| 75 | ) |
| 76 | ) |
| 77 | ) |
| 78 | } |
| 79 | // Add exceptions |
| 80 | sourceFiles.push('CONTRIBUTING.md') |
| 81 | sourceFiles.push('README.md') |
| 82 | verbose && console.log(`${sourceFiles.length.toLocaleString()} source files found in total.`) |
| 83 | |
| 84 | const allImages = new Set( |
| 85 | walk( |
| 86 | 'assets', |
| 87 | Object.assign( |
| 88 | { |
| 89 | globs: ['!**/*.+(md)'], |
| 90 | }, |
| 91 | walkOptions |
| 92 | ) |
| 93 | ).filter((filePath) => !filePath.endsWith('.md')) |
| 94 | ) |
| 95 | |
| 96 | verbose && console.log(`${allImages.size.toLocaleString()} images found in total.`) |
| 97 | |
| 98 | for (const sourceFile of sourceFiles) { |
| 99 | const content = fs.readFileSync(sourceFile, 'utf-8') |
| 100 | for (const imagePath of allImages) { |
no test coverage detected