




















@@ -87,8 +87,10 @@ export type InstalledPluginIndexRecord = {
8787packageInstall?: PluginInstallSourceInfo;
8888manifestPath: string;
8989manifestHash: string;
90-packageJsonPath?: string;
91-packageJsonHash?: string;
90+packageJson?: {
91+path: string;
92+hash: string;
93+};
9294rootDir: string;
9395origin: PluginManifestRecord["origin"];
9496enabled: boolean;
@@ -244,6 +246,30 @@ function resolvePackageJsonPath(candidate: PluginCandidate | undefined): string
244246return fs.existsSync(packageJsonPath) ? packageJsonPath : undefined;
245247}
246248249+function resolvePackageJsonRecord(params: {
250+candidate: PluginCandidate | undefined;
251+packageJsonPath: string | undefined;
252+diagnostics: PluginDiagnostic[];
253+pluginId: string;
254+}): InstalledPluginIndexRecord["packageJson"] | undefined {
255+if (!params.candidate?.packageDir || !params.packageJsonPath) {
256+return undefined;
257+}
258+const hash = safeHashFile({
259+filePath: params.packageJsonPath,
260+pluginId: params.pluginId,
261+diagnostics: params.diagnostics,
262+required: false,
263+});
264+if (!hash) {
265+return undefined;
266+}
267+return {
268+path: path.relative(params.candidate.rootDir, params.packageJsonPath) || "package.json",
269+ hash,
270+};
271+}
272+247273function describePackageInstallSource(
248274candidate: PluginCandidate | undefined,
249275): PluginInstallSourceInfo | undefined {
@@ -416,14 +442,12 @@ function buildInstalledPluginIndex(
416442 diagnostics,
417443required: true,
418444}) ?? "";
419-const packageJsonHash = packageJsonPath
420- ? safeHashFile({
421-filePath: packageJsonPath,
422-pluginId: record.id,
423- diagnostics,
424-required: false,
425-})
426- : undefined;
445+const packageJson = resolvePackageJsonRecord({
446+ candidate,
447+ packageJsonPath,
448+ diagnostics,
449+pluginId: record.id,
450+});
427451const enabled = resolveEffectiveEnableState({
428452id: record.id,
429453origin: record.origin,
@@ -457,11 +481,8 @@ function buildInstalledPluginIndex(
457481if (packageInstall) {
458482indexRecord.packageInstall = packageInstall;
459483}
460-if (packageJsonPath) {
461-indexRecord.packageJsonPath = packageJsonPath;
462-}
463-if (packageJsonHash) {
464-indexRecord.packageJsonHash = packageJsonHash;
484+if (packageJson) {
485+indexRecord.packageJson = packageJson;
465486}
466487return indexRecord;
467488});
@@ -698,7 +719,8 @@ export function diffInstalledPluginIndexInvalidationReasons(
698719}
699720if (
700721previousPlugin.packageVersion !== currentPlugin.packageVersion ||
701-previousPlugin.packageJsonHash !== currentPlugin.packageJsonHash
722+previousPlugin.packageJson?.path !== currentPlugin.packageJson?.path ||
723+previousPlugin.packageJson?.hash !== currentPlugin.packageJson?.hash
702724) {
703725reasons.add("stale-package");
704726}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。