Files
minecraft-bedrock-json-schemas/test/src/utillity.ts

36 lines
914 B
TypeScript
Raw Normal View History

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 {
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");
}
export function GetFiles(cwd: string): string[] {
if (!cwd.endsWith("/") && !cwd.endsWith("\\")) cwd += "/";
2021-08-18 20:48:09 +02:00
cwd = cwd.replace("\\", "/");
2021-08-18 20:48:09 +02: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);
return entries;
2021-08-18 20:15:02 +02:00
}
2021-08-18 17:15:20 +02:00
}