Skip to content

Commit

Permalink
Merge pull request #2063 from Accenture/bug/2061-print-error-if-mcdev…
Browse files Browse the repository at this point in the history
…-validationsjs-could-not-be-loaded-due-to-a-syntax-error

Bug/2061 print error if mcdev validationsjs could not be loaded due to a syntax error
  • Loading branch information
JoernBerkefeld authored Feb 7, 2025
2 parents 2c34c03 + 1af7649 commit ef30819
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/Builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,12 @@ saved
// Clear output folder structure for selected sub-type
// only run this if the standard deploy folder is a target of buildDefinition (which technically could be changed)
Util.logger.info(` - 🚮 purging folder ${deployDir}`);
await File.remove(deployDir);
try {
await File.remove(deployDir);
} catch {
// sometimes the first attempt is not successful for some operating system reason. Trying again mostly solves this
await File.remove(deployDir);
}
}
}

Expand Down
13 changes: 11 additions & 2 deletions lib/util/validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@ let customRules = {};
let customRuleImport;
try {
customRuleImport = await import('file://' + path.join(process.cwd(), '.mcdev-validations.js'));
} catch {
Util.logger.debug('.mcdev-validations.js not found');
} catch (ex) {
if (ex instanceof SyntaxError) {
Util.logger.error('SyntaxError in .mcdev-validations.js: ' + ex.message);
} else if (ex.code === 'ERR_MODULE_NOT_FOUND') {
Util.logger.debug('.mcdev-validations.js not found');
} else {
Util.logger.errorStack(
ex,
'Could not load custom validation rules from .mcdev-validations.js'
);
}
}
/**
*
Expand Down

0 comments on commit ef30819

Please sign in to comment.