Skip to content

Commit

Permalink
feat(backend): replace fs sync function calls with promise api
Browse files Browse the repository at this point in the history
  • Loading branch information
dr460nf1r3 committed Jan 18, 2025
1 parent 2eb4b66 commit bfa0112
Show file tree
Hide file tree
Showing 2 changed files with 173 additions and 146 deletions.
18 changes: 17 additions & 1 deletion backend/src/functions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { CountNameObject, UserAgentList } from '@./shared-lib';
import type { ConfigService } from '@nestjs/config';
import * as bcrypt from 'bcrypt';
import CryptoJs from 'crypto-js';
import constants from 'node:constants';
import { access } from 'node:fs/promises';
import { requiredEnvVarsDev, requiredEnvVarsProd } from './constants';
import { BumpType } from './interfaces/repo-manager';
import CryptoJs from 'crypto-js';

/**
* Parse the output of the non-single line metrics.
Expand Down Expand Up @@ -136,3 +138,17 @@ export function decryptAes(value: string, key: string) {
const bytes = CryptoJs.AES.decrypt(decData, key).toString(CryptoJs.enc.Utf8);
return JSON.parse(bytes);
}

/**
* Check if a file exists
* @param path Path to the file
* @returns True if the file exists, false otherwise
*/
export async function pathExists(path: string): Promise<boolean> {
try {
await access(path, constants.F_OK);
return true;
} catch {
return false;
}
}
Loading

0 comments on commit bfa0112

Please sign in to comment.