[ADF-2911] Improved error message handling in doc tools (#3267)

This commit is contained in:
Andy Stark
2018-05-03 16:39:04 +01:00
committed by Eugenio Romano
parent 96fddbdc39
commit 8f9cb75120
3 changed files with 142 additions and 30 deletions

View File

@@ -47,7 +47,10 @@ function aggPhase(aggData) {
function updatePhase(filenames, aggData) {
var errorMessages;
for (var i = 0; i < filenames.length; i++) {
errorMessages = [];
var pathname = filenames[i]; // path.resolve(srcFolder, filenames[i]);
var src = fs.readFileSync(pathname);
@@ -56,9 +59,13 @@ function updatePhase(filenames, aggData) {
var modified = false;
toolList.forEach(toolName => {
modified |= toolModules[toolName].updatePhase(tree, pathname, aggData);
modified |= toolModules[toolName].updatePhase(tree, pathname, aggData, errorMessages);
});
if (errorMessages.length > 0) {
showErrors(pathname, errorMessages);
}
if (modified)
fs.writeFileSync(filenames[i], remark().use(frontMatter, {type: 'yaml', fence: '---'}).data("settings", {paddedTable: false, gfm: false}).stringify(tree));
@@ -67,6 +74,17 @@ function updatePhase(filenames, aggData) {
}
function showErrors(filename, errorMessages) {
console.log(filename);
errorMessages.forEach(message => {
console.log(" " + message);
});
console.log("");
}
function loadToolModules() {
var mods = {};
var toolsFolderPath = path.resolve(__dirname, toolsFolderName);