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

36 lines
914 B
TypeScript
Raw Normal View History

2021-08-18 20:15:02 +02:00
import FastGlob = require("fast-glob");
import path = require("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 };
let entries = FastGlob.sync(["*.json", "**/*.json"], options);
return entries;
2021-08-18 20:15:02 +02:00
}
2021-08-18 17:15:20 +02:00
}