Skip to content

Commit ef30819

Browse files
Merge pull request #2063 from Accenture/bug/2061-print-error-if-mcdev-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
2 parents 2c34c03 + 1af7649 commit ef30819

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

lib/Builder.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,12 @@ saved
330330
// Clear output folder structure for selected sub-type
331331
// only run this if the standard deploy folder is a target of buildDefinition (which technically could be changed)
332332
Util.logger.info(` - 🚮 purging folder ${deployDir}`);
333-
await File.remove(deployDir);
333+
try {
334+
await File.remove(deployDir);
335+
} catch {
336+
// sometimes the first attempt is not successful for some operating system reason. Trying again mostly solves this
337+
await File.remove(deployDir);
338+
}
334339
}
335340
}
336341

lib/util/validations.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@ let customRules = {};
1313
let customRuleImport;
1414
try {
1515
customRuleImport = await import('file://' + path.join(process.cwd(), '.mcdev-validations.js'));
16-
} catch {
17-
Util.logger.debug('.mcdev-validations.js not found');
16+
} catch (ex) {
17+
if (ex instanceof SyntaxError) {
18+
Util.logger.error('SyntaxError in .mcdev-validations.js: ' + ex.message);
19+
} else if (ex.code === 'ERR_MODULE_NOT_FOUND') {
20+
Util.logger.debug('.mcdev-validations.js not found');
21+
} else {
22+
Util.logger.errorStack(
23+
ex,
24+
'Could not load custom validation rules from .mcdev-validations.js'
25+
);
26+
}
1827
}
1928
/**
2029
*

0 commit comments

Comments
 (0)