([prettierIgnorePath, bundlePath])
| 15 | assert(runfiles, 'Expected `JS_BINARY__RUNFILES` to be set.'); |
| 16 | |
| 17 | async function main([prettierIgnorePath, bundlePath]) { |
| 18 | const prettierIgnoreContent = await readFile(join(runfiles, prettierIgnorePath), 'utf8'); |
| 19 | const ignoredFiles = new Set( |
| 20 | prettierIgnoreContent |
| 21 | .split(/\r?\n/) |
| 22 | .map((line) => line.trim()) |
| 23 | .filter((line) => line && !line.startsWith('#')), |
| 24 | ); |
| 25 | |
| 26 | // The bundlePath is relative to the runfiles, e.g., "devinfra/.github/local-actions/update-models/main.js" |
| 27 | // We need to clean it up to match the relative workspace path. |
| 28 | // Aspect JS rules prefix the path with the workspace name segment (e.g. "_main" or "devinfra"). |
| 29 | // Removing the first segment gets the workspace-relative path. |
| 30 | const relativePath = bundlePath.replace(/^[^/]+\//, ''); |
| 31 | |
| 32 | if (!ignoredFiles.has(relativePath)) { |
| 33 | console.error( |
| 34 | `Error: The checked-in bundle "${relativePath}" is not ignored in .prettierignore.`, |
| 35 | ); |
| 36 | console.error( |
| 37 | `Please add "${relativePath}" to .prettierignore to prevent formatting check-in mismatches.`, |
| 38 | ); |
| 39 | process.exitCode = 1; |
| 40 | } else { |
| 41 | console.info(`Validation passed: "${relativePath}" is correctly ignored in .prettierignore.`); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | main(process.argv.slice(2)).catch((e) => { |
| 46 | console.error(e); |
no test coverage detected