MCPcopy Create free account
hub / github.com/FlashpointProject/launcher / overwriteConfigData

Function overwriteConfigData

src/shared/config/util.ts:63–88  ·  view source on GitHub ↗
(
  source: AppConfigData,
  data: Partial<AppConfigData>,
  onError?: (error: string) => void
)

Source from the content-addressed store, hash-verified

61 * @returns Source argument (not a copy).
62 */
63export 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.

Callers 4

parseFunction · 0.90
registerRequestCallbacksFunction · 0.90
util.tsFile · 0.85

Calls 7

parseVarStrFunction · 0.90
fixSlashesFunction · 0.90
strFunction · 0.85
numFunction · 0.85
toStringMethod · 0.65
propMethod · 0.65
onErrorFunction · 0.50

Tested by

no test coverage detected