no-shot / env
1 1
import { statSync } from "fs";
2

3
/**
4
 * A utility function to check if a file exists.
5
 *
6
 * @param file - filename
7
 * @returns a boolean: whether or not the file exists
8
 */
9 1
function fileExists(file: string): boolean {
10 1
  try {
11 1
    return statSync(file).isFile();
12
  } catch (e) {
13 1
    return false;
14
  }
15
}
16

17 1
export default fileExists;

Read our documentation on viewing source code .

Loading