mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Throw error when check_config fails
This commit is contained in:
parent
3b32605b5e
commit
c7a88e2f12
@ -12,9 +12,7 @@ _This release is scheduled to be released on 2020-07-01._
|
||||
### Added
|
||||
|
||||
- Compliments Module - Add Advice API (https://api.adviceslip.com/) Option
|
||||
|
||||
- Added prettier for an even cleaner codebase
|
||||
|
||||
- Hide Sunrise/Sunset in Weather module
|
||||
|
||||
### Updated
|
||||
@ -37,6 +35,7 @@ _This release is scheduled to be released on 2020-07-01._
|
||||
- Add backward compatibility for old module code in socketclient.js [#1973](https://github.com/MichMich/MagicMirror/issues/1973)
|
||||
- Support multiple instances of calendar module with different config [#1109](https://github.com/MichMich/MagicMirror/issues/1109)
|
||||
- Fix the use of "maxNumberOfDays" in the module "weatherforecast" [#2018](https://github.com/MichMich/MagicMirror/issues/2018)
|
||||
- Throw error when check_config fails [#1928](https://github.com/MichMich/MagicMirror/issues/1928)
|
||||
|
||||
## [2.11.0] - 2020-04-01
|
||||
|
||||
|
@ -1,14 +1,10 @@
|
||||
/* Magic Mirror
|
||||
*
|
||||
* Checker configuration file
|
||||
*
|
||||
* By Rodrigo Ramírez Norambuena
|
||||
* https://rodrigoramirez.com
|
||||
* Check the configuration file for errors
|
||||
*
|
||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||
* MIT Licensed.
|
||||
*
|
||||
*/
|
||||
|
||||
const Linter = require("eslint").Linter;
|
||||
const linter = new Linter();
|
||||
|
||||
@ -34,23 +30,26 @@ function getConfigFile() {
|
||||
|
||||
function checkConfigFile() {
|
||||
const configFileName = getConfigFile();
|
||||
|
||||
// Check if file is present
|
||||
if (fs.existsSync(configFileName) === false) {
|
||||
console.error(Utils.colors.error("File not found: "), configFileName);
|
||||
return;
|
||||
throw new Error("No config file present!");
|
||||
}
|
||||
|
||||
// check permission
|
||||
try {
|
||||
fs.accessSync(configFileName, fs.F_OK);
|
||||
} catch (e) {
|
||||
console.log(Utils.colors.error(e));
|
||||
return;
|
||||
throw new Error("No permission to access config file!");
|
||||
}
|
||||
|
||||
// Validate syntax of the configuration file.
|
||||
// In case the there errors show messages and
|
||||
// return
|
||||
console.info(Utils.colors.info("Checking file... "), configFileName);
|
||||
|
||||
// I'm not sure if all ever is utf-8
|
||||
fs.readFile(configFileName, "utf-8", function (err, data) {
|
||||
if (err) {
|
||||
@ -64,6 +63,7 @@ function checkConfigFile() {
|
||||
messages.forEach((error) => {
|
||||
console.log("Line", error.line, "col", error.column, error.message);
|
||||
});
|
||||
throw new Error("Wrong syntax in config file!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user