From ee07c4d6ec661772745381595ac1ef20f6e46175 Mon Sep 17 00:00:00 2001 From: Alexander Rodionov Date: Fri, 6 Oct 2023 11:03:07 +0400 Subject: [PATCH] refactor: replace `fs.promises` with promisify --- src/Config/SystemConfigReader.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Config/SystemConfigReader.ts b/src/Config/SystemConfigReader.ts index 9e5b49a8..e6e2c689 100644 --- a/src/Config/SystemConfigReader.ts +++ b/src/Config/SystemConfigReader.ts @@ -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; @@ -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 { @@ -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); }