Skip to content

Commit

Permalink
refactor: replace fs.promises with promisify
Browse files Browse the repository at this point in the history
  • Loading branch information
lsndr committed Oct 6, 2023
1 parent ab4e472 commit ee07c4d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Config/SystemConfigReader.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { logger } from '../Utils';
import request, { RequestPromiseAPI } from 'request-promise';
import { promises } from 'fs';
import { readFile, writeFile } from 'fs';
import { join } from 'path';
import { homedir } from 'os';

const { readFile, writeFile } = promises;
import { promisify } from 'util';

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

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

return {
Expand All @@ -116,7 +115,7 @@ export class SystemConfigReader {
logger.debug('Updating system config file');

try {
await writeFile(this.path, JSON.stringify(configFile));
await promisify(writeFile)(this.path, JSON.stringify(configFile));
} catch (e) {
logger.debug('Error during updating system config file', e);
}
Expand Down

0 comments on commit ee07c4d

Please sign in to comment.