MCPcopy Index your code
hub / github.com/ampproject/amphtml / logValidationResult

Function logValidationResult

validator/js/nodejs/index.js:351–371  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

349 * @param {boolean} color
350 */
351function 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.

Callers 1

mainFunction · 0.70

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected