-
Notifications
You must be signed in to change notification settings - Fork 0
/
locator_factory.esm.js
28 lines (22 loc) · 1 KB
/
locator_factory.esm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict';
const NODE_ENV = process.env.NODE_ENV || 'development';
import Locator from './locator.esm.js';
import config from 'config'
/**
* @param {string} relativePathModifierToRoot
* @param {string} locatorConfigPath
* @returns {Locator}
*/
export default async function(relativePathModifierToRoot, locatorConfigPath) {
relativePathModifierToRoot = relativePathModifierToRoot || '../../';
locatorConfigPath = locatorConfigPath || 'config/locator/';
const locatableDirectory = relativePathModifierToRoot + locatorConfigPath;
const locatableDefault = (await import(locatableDirectory + 'default.js')).default;
let locatable = Object.assign({}, locatableDefault);
//load another config based on the environment
try {
let locatableForEnvironment = (await import( locatableDirectory + NODE_ENV + '.js' )).default;
locatable = Object.assign(locatable, locatableForEnvironment);
} catch (e) {}
return new Locator(config, locatable, relativePathModifierToRoot);
};