mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 05:30:42 +00:00
29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
import type { HookInstallRecord } from "../config/types.hooks.js";
|
|
import type { PluginInstallRecord } from "../config/types.plugins.js";
|
|
import { parseRegistryNpmSpec } from "../infra/npm-registry-spec.js";
|
|
|
|
export function extractInstalledNpmPackageName(install: PluginInstallRecord): string | undefined {
|
|
if (install.source !== "npm") {
|
|
return undefined;
|
|
}
|
|
const resolvedName = install.resolvedName?.trim();
|
|
if (resolvedName) {
|
|
return resolvedName;
|
|
}
|
|
return (
|
|
(install.spec ? parseRegistryNpmSpec(install.spec)?.name : undefined) ??
|
|
(install.resolvedSpec ? parseRegistryNpmSpec(install.resolvedSpec)?.name : undefined)
|
|
);
|
|
}
|
|
|
|
export function extractInstalledNpmHookPackageName(install: HookInstallRecord): string | undefined {
|
|
const resolvedName = install.resolvedName?.trim();
|
|
if (resolvedName) {
|
|
return resolvedName;
|
|
}
|
|
return (
|
|
(install.spec ? parseRegistryNpmSpec(install.spec)?.name : undefined) ??
|
|
(install.resolvedSpec ? parseRegistryNpmSpec(install.resolvedSpec)?.name : undefined)
|
|
);
|
|
}
|