src/common/config/index.js
/**
   * Loads and returns locally stored config data from the filesystem or returns app defaults if no file is found
   */
Loads and returns locally stored config data from the filesystem or returns app defaults if no file is found
Loads and returns locally stored config data from the filesystem or returns app defaults if no file is found
loadLocalConfigFile() {
    let configData = {};
    try {
      configData = this.readFileSync(this.configFilePath);
      switch (configData.version) {
      case 1:
        configData = Validator.validateV1ConfigData(configData);
        break;
      default:
        configData = Validator.validateV0ConfigData(configData);
      }
      if (!configData) {
        throw new Error('Provided configuration file does not validate, using defaults instead.');
      }
    } catch (e) {
      console.log('Failed to load configuration file from the filesystem. Using defaults.');
      configData = this.copy(this.defaultConfigData);
      if (!configData.teams.length && this.defaultConfigData.defaultTeam) {
        configData.teams.push(this.defaultConfigData.defaultTeam);
      }
      delete configData.defaultTeam;
      this.writeFileSync(this.configFilePath, configData);
    }
    return configData;
  }
loadLocalConfigFile ( ) { let configData = { } ; try { configData = this . readFileSync ( this . configFilePath ) ; switch ( configData . version ) { case 1 : configData = Validator . validateV1ConfigData ( configData ) ; break ; default : configData = Validator . validateV0ConfigData ( configData ) ; } if ( ! configData ) { throw new Error ( 'Provided configuration file does not validate, using defaults instead.' ) ; } } catch ( e ) { console . log ( 'Failed to load configuration file from the filesystem. Using defaults.' ) ; configData = this . copy ( this . defaultConfigData ) ; if ( ! configData . teams . length && this . defaultConfigData . defaultTeam ) { configData . teams . push ( this . defaultConfigData . defaultTeam ) ; } delete configData . defaultTeam ; this . writeFileSync ( this . configFilePath , configData ) ; } return configData ; }
Loads and returns locally stored config data from the filesystem or returns app defaults if no file is found
Loads and returns locally stored config data from the filesystem or returns app defaults if no file is found
// validate based on config file version // add default team to teams if one exists and there arent currently any teams