@nimpl/i18n 2.0.0-canary.1 → 2.0.0-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configuration/getConfig.js +14 -17
- package/package.json +1 -1
|
@@ -10,25 +10,22 @@ const CONFIG_PATH = path_1.default.join(process.cwd(), "nimpl-i18n.js");
|
|
|
10
10
|
// Crutch bypass of conversion by the assembler to require
|
|
11
11
|
const dynamicImport = new Function("p", "return import(p)");
|
|
12
12
|
const getConfig = async () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
throw new Error(`Can't find load method in configuration file - https://github.com/vordgi/nimpl-i18n#configuration`);
|
|
19
|
-
}
|
|
20
|
-
if (!languages) {
|
|
21
|
-
throw new Error(`Can't find languages list in configuration file - https://github.com/vordgi/nimpl-i18n#configuration`);
|
|
22
|
-
}
|
|
23
|
-
if (!getLanguage) {
|
|
24
|
-
throw new Error(`Can't find getLanguage method in configuration file - https://github.com/vordgi/nimpl-i18n#configuration`);
|
|
25
|
-
}
|
|
26
|
-
return config.default;
|
|
13
|
+
if (fs_1.default.existsSync(CONFIG_PATH)) {
|
|
14
|
+
const config = await dynamicImport((0, url_1.pathToFileURL)(CONFIG_PATH).href);
|
|
15
|
+
const { load, getLanguage, languages } = config.default;
|
|
16
|
+
if (!load) {
|
|
17
|
+
throw new Error(`Can't find "load" method in configuration file - https://github.com/vordgi/nimpl-i18n#configuration`);
|
|
27
18
|
}
|
|
19
|
+
if (!languages) {
|
|
20
|
+
throw new Error(`Can't find "languages" list in configuration file - https://github.com/vordgi/nimpl-i18n#configuration`);
|
|
21
|
+
}
|
|
22
|
+
if (!getLanguage) {
|
|
23
|
+
throw new Error(`Can't find "getLanguage" method in configuration file - https://github.com/vordgi/nimpl-i18n#configuration`);
|
|
24
|
+
}
|
|
25
|
+
return config.default;
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
else {
|
|
28
|
+
throw new Error(`Can't load config from "${CONFIG_PATH}". Read more - https://github.com/vordgi/nimpl-i18n#configuration`);
|
|
31
29
|
}
|
|
32
|
-
throw new Error("Can't load config - https://github.com/vordgi/nimpl-i18n#configuration");
|
|
33
30
|
};
|
|
34
31
|
exports.default = getConfig;
|