add a utility function to check if a file exists
This commit is contained in:
parent
d862768725
commit
9a4bbe2201
1 changed files with 11 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue