add a utility function to check if a file exists

This commit is contained in:
Jacob Kim 2025-06-30 16:51:27 -07:00
parent d862768725
commit 9a4bbe2201

View file

@ -1,8 +1,9 @@
import { expect } from "chai";
import { Key } from "vscode-extension-tester";
import { access, constants } from 'fs/promises';
import * as path from "path";
import { DEFAULT_TIMEOUT } from "./constants";
import path = require("path");
export class TestUtils {
public static CONTINUE_GLOBAL_DIR = process.env.CONTINUE_GLOBAL_DIR ?? "";
@ -11,6 +12,15 @@ export class TestUtils {
return path.join(TestUtils.CONTINUE_GLOBAL_DIR, "index", "globalContext.json");
}
public static async fileExists(path: string): Promise<boolean> {
try {
await access(path, constants.F_OK);
return true;
} catch {
return false;
}
}
/**
* In many cases it might be more useful to use existing Selenium
* utilities. For example: