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/2] 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 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 2/2] 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 {