Added console warning for deprecated config options

This commit is contained in:
Olexandr Savchuk 2016-12-14 18:54:44 +01:00
parent 989dca5792
commit 980b8a2924
4 changed files with 30 additions and 0 deletions

View File

@ -33,6 +33,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Added option `roundTemp` for currentweather and weatherforecast modules to display temperatures rounded to nearest integer. - Added option `roundTemp` for currentweather and weatherforecast modules to display temperatures rounded to nearest integer.
- Added abilty set the classes option to compliments module for style and text size of compliments. - Added abilty set the classes option to compliments module for style and text size of compliments.
- Added ability to configure electronOptions - Added ability to configure electronOptions
- 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

@ -42,6 +42,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) {
@ -58,6 +59,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.
* *