* Logs a validation result to the console using process.stdout and * process.stderr as is appropriate. * @param {string} filename * @param {!ValidationResult} validationResult * @param {boolean} color
(filename, validationResult, color)
| 349 | * @param {boolean} color |
| 350 | */ |
| 351 | function logValidationResult(filename, validationResult, color) { |
| 352 | if (validationResult.status === 'PASS') { |
| 353 | process.stdout.write( |
| 354 | filename + ': ' + (color ? colors.green('PASS') : 'PASS') + '\n'); |
| 355 | } |
| 356 | for (let ii = 0; ii < validationResult.errors.length; ii++) { |
| 357 | const error = validationResult.errors[ii]; |
| 358 | let msg = filename + ':' + error.line + ':' + error.col + ' '; |
| 359 | if (color) { |
| 360 | msg += (error.severity === 'ERROR' ? colors.red : colors.magenta)( |
| 361 | error.message); |
| 362 | } else { |
| 363 | msg += error.message; |
| 364 | } |
| 365 | if (error.specUrl) { |
| 366 | msg += ' (see ' + error.specUrl + ')'; |
| 367 | } |
| 368 | // TODO(powdercloud): Should we distinguish error.severity === 'WARNING' ? |
| 369 | process.stderr.write(msg + '\n'); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * Main entry point into the command line tool. |