Skip to content

Commit

Permalink
refactor: remove config file existing checks
Browse files Browse the repository at this point in the history
  • Loading branch information
lsndr committed Oct 5, 2023
1 parent 969a520 commit 2b64e7a
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions src/Config/SystemConfigReader.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { logger } from '../Utils';
import request, { RequestPromiseAPI } from 'request-promise';
import { promises, constants } from 'fs';
import { promises } from 'fs';
import { join } from 'path';
import { homedir } from 'os';

const { readFile, writeFile, access } = promises;
const { F_OK } = constants;
const { readFile, writeFile } = promises;

export interface SystemConfig {
sentryDsn?: string;
Expand Down Expand Up @@ -98,16 +97,6 @@ export class SystemConfigReader {
try {
logger.debug('Loading system config file');

const configFileExists = await this.configFileExists();

if (!configFileExists) {
logger.debug(
"System config file doesn't exist. Creating a new one with default values"
);

await this.updateConfigFile(defaultConfigFile);
}

const file = await readFile(this.path);
const fileConfig = JSON.parse(file.toString()) as SystemConfigFile;

Expand All @@ -133,16 +122,6 @@ export class SystemConfigReader {
}
}

private async configFileExists(): Promise<boolean> {
try {
await access(this.path, F_OK);

return true;
} catch (e) {
return false;
}
}

private async fetchNewConfig(): Promise<SystemConfig | undefined> {
logger.debug('Fetching new system config');

Expand Down

0 comments on commit 2b64e7a

Please sign in to comment.