mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-10 01:08:23 +01:00
21 lines
537 B
TypeScript
21 lines
537 B
TypeScript
import { promises as fs } from 'fs';
|
|
import path from 'path';
|
|
|
|
/**
|
|
* Check if a file exists at the given path.
|
|
*
|
|
* @param {string} filePath - The path to the file to check.
|
|
* @returns {Promise<boolean>} - True if the path is a file, false otherwise.
|
|
*/
|
|
export const checkFileExists = async (filePath: string): Promise<boolean> => {
|
|
try {
|
|
const resolvedFilePath = path.resolve(filePath);
|
|
|
|
const stats = await fs.stat(resolvedFilePath);
|
|
|
|
return stats.isFile();
|
|
} catch {
|
|
return false;
|
|
}
|
|
};
|