fix(installer): harden readMarketplaceJsonFromDisk and hoist require
- Add try/catch to readMarketplaceJsonFromDisk so malformed JSON returns null instead of throwing an unhandled parse error - Hoist CustomModuleManager require outside the per-module loop in _installOfficialModules
This commit is contained in:
parent
eec011ae9a
commit
ed51e6c538
|
|
@ -569,6 +569,7 @@ class Installer {
|
|||
*/
|
||||
async _installOfficialModules(config, paths, officialModuleIds, addResult, isQuickUpdate, officialModules, ctx) {
|
||||
const { message, installedModuleNames } = ctx;
|
||||
const { CustomModuleManager } = require('../modules/custom-module-manager');
|
||||
|
||||
for (const moduleName of officialModuleIds) {
|
||||
if (installedModuleNames.has(moduleName)) continue;
|
||||
|
|
@ -598,7 +599,6 @@ class Installer {
|
|||
|
||||
// Prefer version from resolution cache (accurate for custom/local modules),
|
||||
// fall back to marketplace.json walk-up for official modules
|
||||
const { CustomModuleManager } = require('../modules/custom-module-manager');
|
||||
const cachedResolution = CustomModuleManager._resolutionCache.get(moduleName);
|
||||
const version = cachedResolution?.version || (sourcePath ? await this._getMarketplaceVersion(sourcePath) : '');
|
||||
addResult(displayName, 'ok', '', { moduleCode: moduleName, newVersion: version });
|
||||
|
|
|
|||
|
|
@ -148,7 +148,11 @@ class CustomModuleManager {
|
|||
async readMarketplaceJsonFromDisk(dirPath) {
|
||||
const marketplacePath = path.join(dirPath, '.claude-plugin', 'marketplace.json');
|
||||
if (!(await fs.pathExists(marketplacePath))) return null;
|
||||
try {
|
||||
return JSON.parse(await fs.readFile(marketplacePath, 'utf8'));
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Discovery ────────────────────────────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Reference in New Issue