mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-27 09:21:35 +07:00
fix(test): normalize path separators [skip ci]
This commit is contained in:
@@ -50,6 +50,14 @@ export function collectFilesSync(
|
||||
return files;
|
||||
}
|
||||
|
||||
export function relativeToCwd(filePath: string): string {
|
||||
return path.relative(process.cwd(), filePath) || filePath;
|
||||
export function toPosixPath(filePath: string): string {
|
||||
if (path.sep === "/") {
|
||||
return filePath;
|
||||
}
|
||||
return filePath.replaceAll("\\", "/");
|
||||
}
|
||||
|
||||
export function relativeToCwd(filePath: string): string {
|
||||
const relativePath = path.relative(process.cwd(), filePath) || filePath;
|
||||
return toPosixPath(relativePath);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,12 @@ import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { collectFilesSync, isCodeFile, relativeToCwd } from "../../scripts/check-file-utils.js";
|
||||
import {
|
||||
collectFilesSync,
|
||||
isCodeFile,
|
||||
relativeToCwd,
|
||||
toPosixPath,
|
||||
} from "../../scripts/check-file-utils.js";
|
||||
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
@@ -37,7 +42,7 @@ describe("scripts/check-file-utils collectFilesSync", () => {
|
||||
|
||||
const files = collectFilesSync(rootDir, {
|
||||
includeFile: (filePath) => filePath.endsWith(".ts"),
|
||||
}).map((filePath) => path.relative(rootDir, filePath));
|
||||
}).map((filePath) => toPosixPath(path.relative(rootDir, filePath)));
|
||||
|
||||
expect(files.toSorted()).toEqual(["src/keep.ts", "src/nested/keep.test.ts"]);
|
||||
});
|
||||
@@ -52,7 +57,7 @@ describe("scripts/check-file-utils collectFilesSync", () => {
|
||||
const files = collectFilesSync(rootDir, {
|
||||
includeFile: (filePath) => filePath.endsWith(".ts"),
|
||||
skipDirNames: new Set(["fixtures"]),
|
||||
}).map((filePath) => path.relative(rootDir, filePath));
|
||||
}).map((filePath) => toPosixPath(path.relative(rootDir, filePath)));
|
||||
|
||||
expect(files).toEqual(["src/keep.ts"]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user