( source: AppConfigData, data: Partial<AppConfigData>, onError?: (error: string) => void )
| 61 | * @returns Source argument (not a copy). |
| 62 | */ |
| 63 | export function overwriteConfigData( |
| 64 | source: AppConfigData, |
| 65 | data: Partial<AppConfigData>, |
| 66 | onError?: (error: string) => void |
| 67 | ): AppConfigData { |
| 68 | const parser = new ObjectParser({ |
| 69 | input: data, |
| 70 | onError: onError && (e => onError(`Error while parsing Config: ${e.toString()}`)), |
| 71 | }); |
| 72 | parser.prop('flashpointPath', v => source.flashpointPath = parseVarStr(str(v))); |
| 73 | parser.prop('useCustomTitlebar', v => source.useCustomTitlebar = !!v); |
| 74 | parser.prop('startServer', v => source.startServer = !!v); |
| 75 | parser.prop('backPortMin', v => source.backPortMin = num(v)); |
| 76 | parser.prop('backPortMax', v => source.backPortMax = num(v)); |
| 77 | parser.prop('imagesPortMin', v => source.imagesPortMin = num(v)); |
| 78 | parser.prop('imagesPortMax', v => source.imagesPortMax = num(v)); |
| 79 | parser.prop('logsBaseUrl', v => source.logsBaseUrl = parseVarStr(str(v))); |
| 80 | parser.prop('updatesEnabled', v => source.updatesEnabled = !!v); |
| 81 | parser.prop('gotdUrl', v => source.gotdUrl = str(v)); |
| 82 | parser.prop('gotdShowAll', v => source.gotdShowAll = !!v); |
| 83 | parser.prop('middlewareOverridePath', v => source.middlewareOverridePath = str(v)); |
| 84 | // Do some alterations |
| 85 | source.flashpointPath = fixSlashes(source.flashpointPath); // (Clean path) |
| 86 | // Return |
| 87 | return source; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Overwrite a config data object with data from another object. |
no test coverage detected