























@@ -5,37 +5,24 @@ import { fileURLToPath } from "node:url";
55import { bundledPluginFile } from "openclaw/plugin-sdk/test-fixtures";
66import { describe, expect, it } from "vitest";
77import { expectNoReaddirSyncDuring } from "../../test-utils/fs-scan-assertions.js";
8+import {
9+listGitTrackedFiles,
10+sortRepoPaths,
11+toRepoRelativePath,
12+} from "../../test-utils/repo-files.js";
813914const thisFilePath = fileURLToPath(import.meta.url);
1015const thisDir = path.dirname(thisFilePath);
1116const repoRoot = path.resolve(thisDir, "../../..");
1217const loadConfigPattern = /\b(?:getRuntimeConfig|config\.getRuntimeConfig)\s*\(/;
131814-function toPosix(relativePath: string): string {
15-return relativePath.split(path.sep).join("/");
16-}
17-1819function readRepoFile(relativePath: string): string {
1920const absolute = path.join(repoRoot, relativePath);
2021return readFileSync(absolute, "utf8");
2122}
22232324function listGitFiles(pathspecs: string[]): string[] | null {
24-const result = spawnSync("git", ["ls-files", "--", ...pathspecs], {
25-cwd: repoRoot,
26-encoding: "utf8",
27-maxBuffer: 1024 * 1024,
28-stdio: ["ignore", "pipe", "ignore"],
29-});
30-if (result.status !== 0) {
31-return null;
32-}
33-return result.stdout
34-.split("\n")
35-.map((line) => line.trim())
36-.filter((line) => line.length > 0)
37-.map(toPosix)
38-.toSorted();
25+return listGitTrackedFiles({ repoRoot, pathspecs });
3926}
40274128function listFindFiles(args: string[]): string[] | null {
@@ -52,9 +39,8 @@ function listFindFiles(args: string[]): string[] | null {
5239.split("\n")
5340.map((line) => line.trim())
5441.filter((line) => line.length > 0)
55-.map((file) => path.relative(repoRoot, file))
56-.map(toPosix)
57-.toSorted();
42+.map((file) => toRepoRelativePath(repoRoot, file))
43+.toSorted((left, right) => left.localeCompare(right));
5844}
59456046function listCoreOutboundEntryFiles(): string[] {
@@ -70,17 +56,16 @@ function listCoreOutboundEntryFiles(): string[] {
7056"*.ts",
7157]);
7258if (externalFiles) {
73-return externalFiles
74-.filter((file) => !file.endsWith(".test.ts"))
75-.map(toPosix)
76-.toSorted();
59+return sortRepoPaths(externalFiles.filter((file) => !file.endsWith(".test.ts")));
7760}
78617962const outboundDir = path.join(repoRoot, "src/channels/plugins/outbound");
8063return fs
8164.readdirSync(outboundDir)
8265.filter((name) => name.endsWith(".ts") && !name.endsWith(".test.ts"))
83-.map((name) => toPosix(path.join("src/channels/plugins/outbound", name)))
66+.map((name) =>
67+toRepoRelativePath(repoRoot, path.join(repoRoot, "src/channels/plugins/outbound", name)),
68+)
8469.toSorted();
8570}
8671@@ -113,7 +98,7 @@ function listExtensionFiles(): {
11398const srcDir = path.join(extensionsRoot, entry.name, "src");
11499const outboundPath = path.join(srcDir, "outbound.ts");
115100if (existsSync(outboundPath)) {
116-adapterEntrypoints.push(toPosix(path.join("extensions", entry.name, "src/outbound.ts")));
101+adapterEntrypoints.push(path.posix.join("extensions", entry.name, "src/outbound.ts"));
117102}
118103119104const channelPath = path.join(srcDir, "channel.ts");
@@ -122,7 +107,7 @@ function listExtensionFiles(): {
122107}
123108const source = readFileSync(channelPath, "utf8");
124109if (/\boutbound\s*:\s*\{/.test(source)) {
125-inlineChannelEntrypoints.push(toPosix(path.join("extensions", entry.name, "src/channel.ts")));
110+inlineChannelEntrypoints.push(path.posix.join("extensions", entry.name, "src/channel.ts"));
126111}
127112}
128113此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。