build(docs-infra): log warning rather than error if content errors are not fatal (#24320)

PR Close #24320
This commit is contained in:
Pete Bacon Darwin
2018-06-06 12:22:25 +01:00
committed by Victor Berchet
parent 68d37ef0c1
commit 700e55ce14
2 changed files with 31 additions and 16 deletions

View File

@ -34,6 +34,7 @@ module.exports = function checkContentRules(log, createDocMessage) {
$runAfter: ['tags-extracted'],
$runBefore: ['processing-docs'],
$process(docs) {
const logMessage = this.failOnContentErrors ? log.error.bind(log) : log.warn.bind(log);
const errors = [];
docs.forEach(doc => {
const docErrors = [];
@ -55,10 +56,10 @@ module.exports = function checkContentRules(log, createDocMessage) {
});
if (errors.length) {
log.error('Content contains errors');
logMessage('Content contains errors');
errors.forEach(docError => {
const errors = docError.errors.join('\n ');
log.error(createDocMessage(errors + '\n ', docError.doc));
logMessage(createDocMessage(errors + '\n ', docError.doc));
});
if (this.failOnContentErrors) {
throw new Error('Stopping due to content errors.');