Skip to content

Commit

Permalink
no need for config variable
Browse files Browse the repository at this point in the history
Co-authored-by: Zefir <[email protected]>
  • Loading branch information
km127pl and zefir-git authored Aug 15, 2023
1 parent c35a9bc commit 983b850
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,17 @@ export class ConfigLoader {
* @throws {SyntaxError} failed to parse config
*/
public static async fromFile(file: string): Promise<Config> {
let config: Config = ConfigLoader.getDefault();
let logger: Logger = new Logger("Config", config.logLevel);
if (!(await ConfigLoader.exists(file))) {
logger.warn("Config does not exist, creating default '%s'", file);
await ConfigLoader.createDefault(file);
const config = ConfigLoader.getDefault();
new Logger("Config", config.logLevel).warn("Config does not exist, creating default '%s'", file);
return config;
}
const fd: FileHandle = await open(file, "r");
const data: string = await fd.readFile("utf-8");
fd.close();

config = JSON.parse(data) as Config;

return config;
return JSON.parse(data) as Config;
}

/**
Expand Down

0 comments on commit 983b850

Please sign in to comment.