(opts)
| 57 | main(program.opts()) |
| 58 | |
| 59 | async function main(opts) { |
| 60 | let errors = 0 |
| 61 | |
| 62 | const files = walk(ASSETS_ROOT, { includeBasePath: true, directories: false }).filter( |
| 63 | (filePath) => { |
| 64 | const basename = path.basename(filePath) |
| 65 | const extension = path.extname(filePath) |
| 66 | return ( |
| 67 | !IGNORE_EXTENSIONS.has(extension) && |
| 68 | basename !== '.DS_Store' && |
| 69 | basename !== 'README.md' && |
| 70 | !filePath.startsWith(EXCLUDE_DIR) |
| 71 | ) |
| 72 | } |
| 73 | ) |
| 74 | const results = (await Promise.all(files.map(checkFile))).filter(Boolean) |
| 75 | for (const [level, filePath, error] of results) { |
| 76 | console.log( |
| 77 | level === CRITICAL ? chalk.red(level) : chalk.yellow(level), |
| 78 | chalk.bold(path.relative(ROOT, filePath)), |
| 79 | error |
| 80 | ) |
| 81 | if (level === CRITICAL) { |
| 82 | errors++ |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | if (opts.verbose) { |
| 87 | console.log(`Checked ${files.length.toLocaleString()} images`) |
| 88 | const countWarnings = results.filter(([level]) => level === WARNING).length |
| 89 | const countCritical = results.filter(([level]) => level === CRITICAL).length |
| 90 | const wrap = countCritical ? chalk.red : countWarnings ? chalk.yellow : chalk.green |
| 91 | console.log(wrap(`Found ${countCritical} critical errors and ${countWarnings} warnings`)) |
| 92 | } |
| 93 | |
| 94 | process.exitCode = errors |
| 95 | } |
| 96 | |
| 97 | async function checkFile(filePath) { |
| 98 | const ext = path.extname(filePath) |
no outgoing calls
no test coverage detected