build(aio): improve error message for ignored example files (#19265)

Addresses https://github.com/angular/angular/pull/18707#issuecomment-330396771

PR Close #19265
This commit is contained in:
Peter Bacon Darwin
2017-09-19 10:15:39 +01:00
committed by Igor Minar
parent 988b9f8378
commit 381e680758
5 changed files with 209 additions and 149 deletions

View File

@ -14,15 +14,22 @@ module.exports = function getExampleRegion(exampleMap, createDocMessage, collect
// If still no file then we error
if (!exampleFile) {
const message = createDocMessage('Missing example file... relativePath: "' + relativePath + '".', doc) + '\n' +
'Example files can be found in: ' + EXAMPLES_FOLDERS.join(', ');
throw new Error(message);
const gitIgnoreFile = collectExamples.isExampleIgnored(relativePath);
if( gitIgnoreFile) {
const message = createDocMessage('Ignored example file... relativePath: "' + relativePath + '"', doc) + '\n' +
'This example file exists but has been ignored by a rule, in "' + gitIgnoreFile + '".';
throw new Error(message);
} else {
const message = createDocMessage('Missing example file... relativePath: "' + relativePath + '".', doc) + '\n' +
'Example files can be found in the following relative paths: ' + EXAMPLES_FOLDERS.map(function(folder) { return '"' + folder + '"'; }).join(', ');
throw new Error(message);
}
}
var sourceCodeDoc = exampleFile.regions[regionName || ''];
if (!sourceCodeDoc) {
const message = createDocMessage('Missing example region... relativePath: "' + relativePath + '", region: "' + regionName + '".', doc) + '\n' +
'Regions available are:' + Object.keys[exampleFile.regions];
'Regions available are: ' + Object.keys(exampleFile.regions).map(function(region) { return '"' + region + '"'; }).join(', ');
throw new Error(message);
}