config: remove all async/await around config read functions

Now that reading is synchronous, there's no need to have any more
async/await in regards to the those config functions.
This commit is contained in:
Jordi Gutiérrez Hermoso
2024-07-17 17:46:28 -04:00
committed by jordigh
parent 4013382170
commit e30a090a4e
7 changed files with 20 additions and 20 deletions

View File

@@ -56,15 +56,15 @@ export class FileConfig<FileContents> {
* @param validator - Validates the contents are in the correct format, and converts to the correct type.
* Should throw an error or return null if not valid.
*/
public static async create<CreateConfigFileContents>(
public static create<CreateConfigFileContents>(
configPath: string,
validator: FileContentsValidator<CreateConfigFileContents>
): Promise<FileConfig<CreateConfigFileContents>> {
): FileConfig<CreateConfigFileContents> {
// Start with empty object, as it can be upgraded to a full config.
let rawFileContents: any = {};
if (await Deps.pathExists(configPath)) {
rawFileContents = JSON.parse(await Deps.readFile(configPath, 'utf8'));
if (Deps.pathExists(configPath)) {
rawFileContents = JSON.parse(Deps.readFile(configPath, 'utf8'));
}
let fileContents = null;
@@ -97,7 +97,7 @@ export class FileConfig<FileContents> {
await this.persistToDisk();
}
public async persistToDisk(): Promise<void> {
public async persistToDisk() {
await Deps.writeFile(this._filePath, JSON.stringify(this._rawConfig, null, 2));
}
}

View File

@@ -15,8 +15,8 @@ export interface IGristCoreConfig {
edition: IWritableConfigValue<Edition>;
}
export async function loadGristCoreConfigFile(configPath?: string): Promise<IGristCoreConfig> {
const fileConfig = configPath ? await FileConfig.create(configPath, convertToCoreFileContents) : undefined;
export function loadGristCoreConfigFile(configPath?: string): IGristCoreConfig {
const fileConfig = configPath ? FileConfig.create(configPath, convertToCoreFileContents) : undefined;
return loadGristCoreConfig(fileConfig);
}

View File

@@ -71,7 +71,7 @@ export async function main(port: number, serverTypes: ServerType[],
const includeStatic = serverTypes.includes("static");
const includeApp = serverTypes.includes("app");
options.settings ??= await getGlobalConfig();
options.settings ??= getGlobalConfig();
const server = new FlexServer(port, `server(${serverTypes.join(",")})`, options);