2024-11-09 10:08:30 +01:00
|
|
|
import * as FastGlob from "fast-glob";
|
|
|
|
|
import * as path from "path";
|
2021-08-18 17:15:20 +02:00
|
|
|
|
|
|
|
|
export namespace Files {
|
2021-08-18 20:15:02 +02:00
|
|
|
export function TestFolder(): string {
|
2023-02-21 19:21:04 +01:00
|
|
|
return path.join(__dirname, "..", "..", "test");
|
2021-08-18 20:15:02 +02:00
|
|
|
}
|
2021-08-18 17:15:20 +02:00
|
|
|
|
2021-08-18 20:15:02 +02:00
|
|
|
export function RootFolder(): string {
|
|
|
|
|
return path.join(TestFolder(), "..");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function FilesFolder(): string {
|
|
|
|
|
return path.join(TestFolder(), "files");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function CorrectFilesFolder(): string {
|
|
|
|
|
return path.join(FilesFolder(), "correct");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function InCorrectFilesFolder(): string {
|
|
|
|
|
return path.join(FilesFolder(), "incorrect");
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-21 19:21:04 +01:00
|
|
|
export function GetFiles(cwd: string): string[] {
|
|
|
|
|
if (!cwd.endsWith("/") && !cwd.endsWith("\\")) cwd += "/";
|
2021-08-18 20:48:09 +02:00
|
|
|
|
2023-02-21 19:21:04 +01:00
|
|
|
cwd = cwd.replace("\\", "/");
|
2021-08-18 20:48:09 +02:00
|
|
|
|
2023-02-21 19:21:04 +01:00
|
|
|
const options: FastGlob.Options = { onlyFiles: true, absolute: true, cwd: cwd };
|
2024-08-18 17:55:00 +02:00
|
|
|
const entries = FastGlob.sync(["*.json", "**/*.json"], options);
|
2023-02-21 19:21:04 +01:00
|
|
|
|
|
|
|
|
return entries;
|
2021-08-18 20:15:02 +02:00
|
|
|
}
|
2021-08-18 17:15:20 +02:00
|
|
|
}
|