loadConfigFile() {
		let filePath;
		// Env vars have priority over the flags
		const configPath = process.env["MOLECULER_CONFIG"] || this.flags.config;

		if (configPath != null) {
			if (path.isAbsolute(configPath)) {
				filePath = this.tryConfigPath(configPath);
			} else {
				filePath = this.tryConfigPath(path.resolve(process.cwd(), configPath));

				if (filePath == null) {
					filePath = this.tryConfigPath(configPath, true);
				}
			}

			if (filePath == null) {
				return Promise.reject(new Error(`Config file not found: ${configPath}`));
			}
		}

		if (filePath == null) {
			filePath = this.tryConfigPath(path.resolve(process.cwd(), "moleculer.config.js"));
		}
		if (filePath == null) {
			filePath = this.tryConfigPath(path.resolve(process.cwd(), "moleculer.config.json"));
		}

		if (filePath == null) {
			// no configuration file found
			return Promise.resolve({});
		}

		const ext = path.extname(filePath);
		switch (ext) {
			case ".json":
			case ".js":
			case ".ts": {
				return Promise.resolve(require(filePath))
					.then(content => {
						return content.default != null && content.__esModule
							? content.default
							: content;
					})
					.then(mod => {
						return utils.isFunction(mod) ? mod.call(this) : mod;
					});
			}
			default:
				return Promise.reject(new Error(`Not supported file extension: ${ext}`));
		}
	}
Load configuration file

Try to load a configuration file in order to:

		- load file defined in MOLECULER_CONFIG env var
		- try to load file which is defined in CLI option with --config
		- try to load the `moleculer.config.js` file if exist in the cwd
		- try to load the `moleculer.config.json` file if exist in the cwd