Skip to content

Commit

Permalink
feat: add support for globalConfig.yaml as well as JSON (#116)
Browse files Browse the repository at this point in the history
* feat(code): ADDON-56381 Added support for YAML file

* feat(code): ADDON-56381 Removing the comment
  • Loading branch information
tbalar-splunk committed Oct 10, 2022
1 parent 22f1d31 commit 725bc5c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ui/src/main/webapp/util/script.js
Expand Up @@ -14,9 +14,19 @@ export function getBuildDirPath() {
return '';
}

export function loadGlobalConfig() {
// Get the configuraiton json file in sync mode
function loadJSONFile() {
return axios.get(`${getBuildDirPath()}/globalConfig.json`).then((res) => {
return typeof res.data === 'object' ? res.data : JSON.parse(res.data);
});
}

function loadYAMLFile() {
const yaml = require('js-yaml');
return axios.get(`${getBuildDirPath()}/globalConfig.yaml`).then((res) => {
return typeof res.data === 'object' ? res.data : yaml.load(res.data);
});
}

export function loadGlobalConfig() {
return loadJSONFile().catch(e => loadYAMLFile());
}

0 comments on commit 725bc5c

Please sign in to comment.