async function loadConfig () {
		Log.log("Loading config ...");
		const defaults = require(`${__dirname}/defaults`);
		if (process.env.JEST_WORKER_ID !== undefined) {
			// if we are running with jest
			defaults.address = "0.0.0.0";
		}

		// For this check proposed to TestSuite
		// https://forum.magicmirror.builders/topic/1456/test-suite-for-magicmirror/8
		const configFilename = path.resolve(global.configuration_file || `${global.root_path}/config/config.js`);
		let templateFile = `${configFilename}.template`;

		// check if templateFile exists
		try {
			fs.accessSync(templateFile, fs.F_OK);
		} catch (err) {
			templateFile = null;
			Log.log("config template file not exists, no envsubst");
		}

		if (templateFile) {
			// save current config.js
			try {
				if (fs.existsSync(configFilename)) {
					fs.copyFileSync(configFilename, `${configFilename}-old`);
				}
			} catch (err) {
				Log.warn(`Could not copy ${configFilename}: ${err.message}`);
			}

			// check if config.env exists
			const envFiles = [];
			const configEnvFile = `${configFilename.substr(0, configFilename.lastIndexOf("."))}.env`;
			try {
				if (fs.existsSync(configEnvFile)) {
					envFiles.push(configEnvFile);
				}
			} catch (err) {
				Log.log(`${configEnvFile} does not exist. ${err.message}`);
			}

			let options = {
				all: true,
				diff: false,
				envFiles: envFiles,
				protect: false,
				syntax: "default",
				system: true
			};

			// envsubst variables in templateFile and create new config.js
			// naming for envsub must be templateFile and outputFile
			const outputFile = configFilename;
			try {
				await envsub({ templateFile, outputFile, options });
			} catch (err) {
				Log.error(`Could not envsubst variables: ${err.message}`);
			}
		}

		require(`${global.root_path}/js/check_config.js`);

		try {
			fs.accessSync(configFilename, fs.F_OK);
			const c = require(configFilename);
			if (Object.keys(c).length === 0) {
				Log.error("WARNING! Config file appears empty, maybe missing module.exports last line?");
			}
			checkDeprecatedOptions(c);
			return Object.assign(defaults, c);
		} catch (e) {
			if (e.code === "ENOENT") {
				Log.error("WARNING! Could not find config file. Please create one. Starting with default configuration.");
			} else if (e instanceof ReferenceError || e instanceof SyntaxError) {
				Log.error(`WARNING! Could not validate config file. Starting with default configuration. Please correct syntax errors at or above this line: ${e.stack}`);
			} else {
				Log.error(`WARNING! Could not load config file. Starting with default configuration. Error found: ${e}`);
			}
		}

		return defaults;
	}
Loads the config file. Combines it with the defaults and returns the config
@async
@returns {Promise<object>} the loaded config or the defaults if something goes wrong