From 86e553e756fed4f327ff9b014b1dcf760309638e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Tue, 24 Jan 2017 02:59:20 -0300 Subject: [PATCH 1/6] Set configuration file by enviroment variable: Enable ability to set configuration file by the enviroment variable called MM_CONFIG_FILE. --- CHANGELOG.md | 1 + js/app.js | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d4563d3..347099e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Option to use RegExp in Calendar's titleReplace. - Hungarian Translation. - Icelandic Translation. +- Enable ability to set configuration file by the enviroment variable called MM_CONFIG_FILE. ### Fixed - Update .gitignore to not ignore default modules folder. diff --git a/js/app.js b/js/app.js index 91149906..2eda7d1e 100644 --- a/js/app.js +++ b/js/app.js @@ -17,6 +17,10 @@ console.log("Starting MagicMirror: v" + global.version); // global absolute root path global.root_path = path.resolve(__dirname + "/../"); +if (process.env.MM_CONFIG_FILE) { + global.configuration_file = process.env.MM_CONFIG_FILE; +} + // The next part is here to prevent a major exception when there // is no internet connection. This could probable be solved better. process.on("uncaughtException", function (err) { @@ -41,7 +45,16 @@ var App = function() { var loadConfig = function(callback) { console.log("Loading config ..."); var defaults = require(__dirname + "/defaults.js"); - var configFilename = path.resolve(global.root_path + "/config/config.js"); + + // For this check proposed to TestSuite + // https://forum.magicmirror.builders/topic/1456/test-suite-for-magicmirror/8 + console.log(global.configuration_file); + if (global.configuration_file === undefined ) { + var configFilename = path.resolve(global.root_path + "/config/config.js"); + } else { + var configFilename = path.resolve(global.configuration_file); + } + try { fs.accessSync(configFilename, fs.F_OK); var c = require(configFilename); From 7dbfa0b2030d75cdb8d6e51d29bb2e621cc2859d Mon Sep 17 00:00:00 2001 From: Chris van Marle Date: Tue, 24 Jan 2017 12:22:43 +0100 Subject: [PATCH 2/6] Add root_path testing --- tests/global_vars/root_path.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/global_vars/root_path.js diff --git a/tests/global_vars/root_path.js b/tests/global_vars/root_path.js new file mode 100644 index 00000000..bcb6c509 --- /dev/null +++ b/tests/global_vars/root_path.js @@ -0,0 +1,24 @@ +var fs = require("fs"); +var path = require("path"); +var chai = require("chai"); +var expect = chai.expect; +var appMM = require("../../js/app.js") + +describe("Test global.root_path, set in js/app.js", function() { + var expectedSubPaths = [ + 'modules', + 'serveronly', + 'js', + 'js/app.js', + 'js/main.js', + 'js/electron.js', + 'config' + ]; + + expectedSubPaths.forEach(subpath => { + it(`should contain a file/folder "${subpath}"`, function() { + expect(fs.existsSync(path.join(global.root_path, subpath))).to.equal(true); + }); + }); +}); + From 422349c2d135e7926bb1d71932eb15eecce95e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Tue, 24 Jan 2017 17:22:17 -0300 Subject: [PATCH 3/6] Change of examples configuration in README modules. This change is related commit f59f035a7ec5e64ab9e629521b39a548a6430b8b Now is used grunt for check ESLint syntax validation of config/* files --- modules/default/alert/README.md | 2 +- modules/default/calendar/README.md | 4 +-- modules/default/clock/README.md | 4 +-- modules/default/compliments/README.md | 28 ++++++++++---------- modules/default/currentweather/README.md | 10 +++---- modules/default/helloworld/README.md | 6 ++--- modules/default/newsfeed/README.md | 4 +-- modules/default/updatenotification/README.md | 4 +-- modules/default/weatherforecast/README.md | 10 +++---- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/modules/default/alert/README.md b/modules/default/alert/README.md index 89505d16..58be0570 100644 --- a/modules/default/alert/README.md +++ b/modules/default/alert/README.md @@ -7,7 +7,7 @@ To use this module, add it to the modules array in the config/config.js file: ``` modules: [ { - module: 'alert', + module: "alert", config: { // The config property is optional. // See 'Configuration options' for more information. diff --git a/modules/default/calendar/README.md b/modules/default/calendar/README.md index 06b7dd9c..d7eabe78 100644 --- a/modules/default/calendar/README.md +++ b/modules/default/calendar/README.md @@ -8,8 +8,8 @@ To use this module, add it to the modules array in the `config/config.js` file: ````javascript modules: [ { - module: 'calendar', - position: 'top_left', // This can be any of the regions. Best results in left or right regions. + module: "calendar", + position: "top_left", // This can be any of the regions. Best results in left or right regions. config: { // The config property is optional. // If no config is set, an example calendar is shown. diff --git a/modules/default/clock/README.md b/modules/default/clock/README.md index 9bd0bafd..5570ff5a 100644 --- a/modules/default/clock/README.md +++ b/modules/default/clock/README.md @@ -8,8 +8,8 @@ To use this module, add it to the modules array in the `config/config.js` file: ````javascript modules: [ { - module: 'clock', - position: 'top_left', // This can be any of the regions. + module: "clock", + position: "top_left", // This can be any of the regions. config: { // The config property is optional. // See 'Configuration options' for more information. diff --git a/modules/default/compliments/README.md b/modules/default/compliments/README.md index d8be85d2..8ef9e2fb 100644 --- a/modules/default/compliments/README.md +++ b/modules/default/compliments/README.md @@ -8,8 +8,8 @@ To use this module, add it to the modules array in the `config/config.js` file: ````javascript modules: [ { - module: 'compliments', - position: 'lower_third', // This can be any of the regions. + module: "compliments", + position: "lower_third", // This can be any of the regions. // Best results in one of the middle regions like: lower_third config: { // The config property is optional. @@ -60,14 +60,14 @@ If use the currentweather is possible use a actual weather for set compliments. config: { compliments: { day_sunny: [ - 'Today is a sunny day', - 'It\'s a beautiful day' + "Today is a sunny day", + "It's a beautiful day" ], snow: [ - 'Snowball battle!' + "Snowball battle!" ], rain: [ - 'Don\'t forget your umbrella' + "Don't forget your umbrella" ] } } @@ -79,19 +79,19 @@ config: { config: { compliments: { morning: [ - 'Good morning, handsome!', - 'Enjoy your day!', - 'How was your sleep?' + "Good morning, handsome!", + "Enjoy your day!", + "How was your sleep?" ], afternoon: [ - 'Hello, beauty!', + "Hello, beauty!", 'You look sexy!', - 'Looking good today!' + "Looking good today!" ], evening: [ - 'Wow, you look hot!', - 'You look nice!', - 'Hi, sexy!' + "Wow, you look hot!", + "You look nice!", + "Hi, sexy!" ] } } diff --git a/modules/default/currentweather/README.md b/modules/default/currentweather/README.md index 36a8a436..65913d82 100644 --- a/modules/default/currentweather/README.md +++ b/modules/default/currentweather/README.md @@ -8,14 +8,14 @@ To use this module, add it to the modules array in the `config/config.js` file: ````javascript modules: [ { - module: 'currentweather', - position: 'top_right', // This can be any of the regions. + module: "currentweather", + position: "top_right", // This can be any of the regions. // Best results in left or right regions. config: { // See 'Configuration options' for more information. - location: 'Amsterdam,Netherlands', - locationID: '', //Location ID from http://openweathermap.org/help/city_list.txt - appid: 'abcde12345abcde12345abcde12345ab' //openweathermap.org API key. + location: "Amsterdam,Netherlands", + locationID: "", //Location ID from http://openweathermap.org/help/city_list.txt + appid: "abcde12345abcde12345abcde12345ab" //openweathermap.org API key. } } ] diff --git a/modules/default/helloworld/README.md b/modules/default/helloworld/README.md index bcbd57fc..d86fce3d 100644 --- a/modules/default/helloworld/README.md +++ b/modules/default/helloworld/README.md @@ -6,11 +6,11 @@ To use this module, add it to the modules array in the `config/config.js` file: ````javascript modules: [ { - module: 'helloworld', - position: 'bottom_bar', // This can be any of the regions. + module: "helloworld", + position: "bottom_bar", // This can be any of the regions. config: { // See 'Configuration options' for more information. - text: 'Hello world!' + text: "Hello world!" } } ] diff --git a/modules/default/newsfeed/README.md b/modules/default/newsfeed/README.md index 20840806..bfaa1aad 100644 --- a/modules/default/newsfeed/README.md +++ b/modules/default/newsfeed/README.md @@ -9,8 +9,8 @@ To use this module, add it to the modules array in the `config/config.js` file: ````javascript modules: [ { - module: 'newsfeed', - position: 'bottom_bar', // This can be any of the regions. Best results in center regions. + module: "newsfeed", + position: "bottom_bar", // This can be any of the regions. Best results in center regions. config: { // The config property is optional. // If no config is set, an example calendar is shown. diff --git a/modules/default/updatenotification/README.md b/modules/default/updatenotification/README.md index 16a1b0c2..54ba213a 100644 --- a/modules/default/updatenotification/README.md +++ b/modules/default/updatenotification/README.md @@ -8,8 +8,8 @@ To use this module, add it to the modules array in the `config/config.js` file: ````javascript modules: [ { - module: 'updatenotification', - position: 'top_center', // This can be any of the regions. + module: "updatenotification", + position: "top_center", // This can be any of the regions. config: { // The config property is optional. // See 'Configuration options' for more information. diff --git a/modules/default/weatherforecast/README.md b/modules/default/weatherforecast/README.md index e2cc5028..9298c0cc 100644 --- a/modules/default/weatherforecast/README.md +++ b/modules/default/weatherforecast/README.md @@ -8,14 +8,14 @@ To use this module, add it to the modules array in the `config/config.js` file: ````javascript modules: [ { - module: 'weatherforecast', - position: 'top_right', // This can be any of the regions. + module: "weatherforecast", + position: "top_right", // This can be any of the regions. // Best results in left or right regions. config: { // See 'Configuration options' for more information. - location: 'Amsterdam,Netherlands', - locationID: '', //Location ID from http://openweathermap.org/help/city_list.txt - appid: 'abcde12345abcde12345abcde12345ab' //openweathermap.org API key. + location: "Amsterdam,Netherlands", + locationID: "", //Location ID from http://openweathermap.org/help/city_list.txt + appid: "abcde12345abcde12345abcde12345ab" //openweathermap.org API key. } } ] From 36ead2251a98ee058a748dddc868dca23c59ebca Mon Sep 17 00:00:00 2001 From: Chris van Marle Date: Wed, 25 Jan 2017 11:58:20 +0100 Subject: [PATCH 4/6] Fix grunt errors --- tests/global_vars/root_path.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/global_vars/root_path.js b/tests/global_vars/root_path.js index bcb6c509..04edc03f 100644 --- a/tests/global_vars/root_path.js +++ b/tests/global_vars/root_path.js @@ -2,17 +2,18 @@ var fs = require("fs"); var path = require("path"); var chai = require("chai"); var expect = chai.expect; -var appMM = require("../../js/app.js") describe("Test global.root_path, set in js/app.js", function() { + var appMM = require("../../js/app.js") + var expectedSubPaths = [ - 'modules', - 'serveronly', - 'js', - 'js/app.js', - 'js/main.js', - 'js/electron.js', - 'config' + "modules", + "serveronly", + "js", + "js/app.js", + "js/main.js", + "js/electron.js", + "config" ]; expectedSubPaths.forEach(subpath => { From ae41ed1d518d26847d79c65e403fcac1be117cb8 Mon Sep 17 00:00:00 2001 From: Chris van Marle Date: Wed, 25 Jan 2017 12:00:38 +0100 Subject: [PATCH 5/6] Fix syntax in DA translation --- translations/da.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translations/da.json b/translations/da.json index 4b346437..5ad271fe 100644 --- a/translations/da.json +++ b/translations/da.json @@ -25,7 +25,7 @@ "W": "V", "WNW": "VNV", "NW": "NV", - "NNW": "NNV" + "NNW": "NNV", /* UPDATE INFO */ From 3818e48218d89c79d43caad062cf27146cb4627a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Wed, 25 Jan 2017 19:05:40 -0300 Subject: [PATCH 6/6] remove console.log --- js/app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/app.js b/js/app.js index 2eda7d1e..83d637b2 100644 --- a/js/app.js +++ b/js/app.js @@ -48,7 +48,6 @@ var App = function() { // For this check proposed to TestSuite // https://forum.magicmirror.builders/topic/1456/test-suite-for-magicmirror/8 - console.log(global.configuration_file); if (global.configuration_file === undefined ) { var configFilename = path.resolve(global.root_path + "/config/config.js"); } else {