Added console warning for deprecated config options

This commit is contained in:
Olexandr Savchuk 2016-12-14 18:54:44 +01:00
parent 9bd42ac221
commit 90616c82b6
4 changed files with 30 additions and 0 deletions

View File

@ -70,6 +70,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Added ability to configure electronOptions - Added ability to configure electronOptions
- Calendar module: option to hide private events - Calendar module: option to hide private events
- Add root_path for global vars - Add root_path for global vars
- Added console warning on startup when deprecated config options are used
### Updated ### Updated
- Modified translations for Frysk. - Modified translations for Frysk.

1
config/.gitignore vendored
View File

@ -1,2 +1,3 @@
* *
!config.js.sample !config.js.sample
!deprecated.js

12
config/deprecated.js Normal file
View File

@ -0,0 +1,12 @@
/* Magic Mirror Deprecated Config Options List
*
* By Michael Teeuw http://michaelteeuw.nl
* MIT Licensed.
*/
var deprecated = [
'kioskmode'
];
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== 'undefined') {module.exports = deprecated;}

View File

@ -56,6 +56,7 @@ var App = function() {
try { try {
fs.accessSync(configFilename, fs.F_OK); fs.accessSync(configFilename, fs.F_OK);
var c = require(configFilename); var c = require(configFilename);
checkDeprecatedOptions(c);
var config = Object.assign(defaults, c); var config = Object.assign(defaults, c);
callback(config); callback(config);
} catch (e) { } catch (e) {
@ -72,6 +73,21 @@ var App = function() {
} }
}; };
var checkDeprecatedOptions = function(userConfig) {
var deprecatedOptions = require(__dirname + "/../config/deprecated.js");
var usedDeprecated = [];
deprecatedOptions.forEach(function(option) {
if (userConfig.hasOwnProperty(option)) {
usedDeprecated.push(option);
}
});
if (usedDeprecated.length > 0) {
console.error("WARNING! Your config is using deprecated options: " + usedDeprecated.join(", ") + ". Check README and CHANGELOG for more up-to-date ways of getting the same functionality.");
}
}
/* loadModule(module) /* loadModule(module)
* Loads a specific module. * Loads a specific module.
* *