mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 20:24:46 +00:00
fix(test): avoid scanning extension ids
This commit is contained in:
@@ -70,11 +70,19 @@ function listChangedPaths(base, head = "HEAD") {
|
||||
.filter((line) => line.length > 0);
|
||||
}
|
||||
|
||||
function hasExtensionPackage(extensionId) {
|
||||
return fs.existsSync(path.join(repoRoot, BUNDLED_PLUGIN_ROOT_DIR, extensionId, "package.json"));
|
||||
function listAvailableExtensionIdsFromGit() {
|
||||
const packageFiles = runGit(["ls-files", "--", `:(glob)${BUNDLED_PLUGIN_PATH_PREFIX}*/package.json`])
|
||||
.split("\n")
|
||||
.map((line) => normalizeRelative(line.trim()))
|
||||
.filter((line) => line.length > 0);
|
||||
return packageFiles
|
||||
.map((file) => file.match(new RegExp(`^${BUNDLED_PLUGIN_PATH_PREFIX}([^/]+)/package\\.json$`)))
|
||||
.filter((match) => match)
|
||||
.map((match) => match[1])
|
||||
.toSorted((left, right) => left.localeCompare(right));
|
||||
}
|
||||
|
||||
export function listAvailableExtensionIds() {
|
||||
function listAvailableExtensionIdsFromDirectory() {
|
||||
const extensionsDir = path.join(repoRoot, BUNDLED_PLUGIN_ROOT_DIR);
|
||||
if (!fs.existsSync(extensionsDir)) {
|
||||
return [];
|
||||
@@ -84,11 +92,22 @@ export function listAvailableExtensionIds() {
|
||||
.readdirSync(extensionsDir, { withFileTypes: true })
|
||||
.filter((entry) => entry.isDirectory())
|
||||
.map((entry) => entry.name)
|
||||
.filter((extensionId) => hasExtensionPackage(extensionId))
|
||||
.filter((extensionId) =>
|
||||
fs.existsSync(path.join(repoRoot, BUNDLED_PLUGIN_ROOT_DIR, extensionId, "package.json")),
|
||||
)
|
||||
.toSorted((left, right) => left.localeCompare(right));
|
||||
}
|
||||
|
||||
export function listAvailableExtensionIds() {
|
||||
try {
|
||||
return listAvailableExtensionIdsFromGit();
|
||||
} catch {
|
||||
return listAvailableExtensionIdsFromDirectory();
|
||||
}
|
||||
}
|
||||
|
||||
export function detectChangedExtensionIds(changedPaths) {
|
||||
const availableExtensionIds = new Set(listAvailableExtensionIds());
|
||||
const extensionIds = new Set();
|
||||
|
||||
for (const rawPath of changedPaths) {
|
||||
@@ -102,14 +121,14 @@ export function detectChangedExtensionIds(changedPaths) {
|
||||
);
|
||||
if (extensionMatch) {
|
||||
const extensionId = extensionMatch[1];
|
||||
if (hasExtensionPackage(extensionId)) {
|
||||
if (availableExtensionIds.has(extensionId)) {
|
||||
extensionIds.add(extensionId);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
const pairedCoreMatch = relativePath.match(/^src\/([^/]+)(?:\/|$)/);
|
||||
if (pairedCoreMatch && hasExtensionPackage(pairedCoreMatch[1])) {
|
||||
if (pairedCoreMatch && availableExtensionIds.has(pairedCoreMatch[1])) {
|
||||
extensionIds.add(pairedCoreMatch[1]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user