MCPcopy Index your code
hub / github.com/ether/etherpad / parseSettings

Function parseSettings

src/node/utils/Settings.ts:93–132  ·  view source on GitHub ↗
(settingsFilename: string, isSettings: boolean)

Source from the content-addressed store, hash-verified

91 * The isSettings variable only controls the error logging.
92 */
93const parseSettings = (settingsFilename: string, isSettings: boolean) => {
94 let settingsStr = '';
95
96 let settingsType, notFoundMessage, notFoundFunction;
97
98 if (isSettings) {
99 settingsType = 'settings';
100 notFoundMessage = 'Continuing using defaults!';
101 notFoundFunction = logger.warn.bind(logger);
102 } else {
103 settingsType = 'credentials';
104 notFoundMessage = 'Ignoring.';
105 notFoundFunction = logger.info.bind(logger);
106 }
107
108 try {
109 // read the settings file
110 settingsStr = fs.readFileSync(settingsFilename).toString();
111 } catch (e) {
112 notFoundFunction(`No ${settingsType} file found in ${settingsFilename}. ${notFoundMessage}`);
113
114 // or maybe undefined!
115 return null;
116 }
117
118 try {
119 settingsStr = jsonminify(settingsStr).replace(',]', ']').replace(',}', '}');
120
121 const settings = JSON.parse(settingsStr);
122
123 logger.info(`${settingsType} loaded from: ${settingsFilename}`);
124
125 return lookupEnvironmentVariables(settings);
126 } catch (e: any) {
127 logger.error(`There was an error processing your ${settingsType} ` +
128 `file from ${settingsFilename}: ${e.message}`);
129
130 process.exit(1);
131 }
132};
133
134
135// Provide git version if available

Callers 1

reloadSettingsFunction · 0.85

Calls 4

parseMethod · 0.80
bindMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected