@@ -42,8 +42,10 @@ const tempDirs: string[] = [];
4242
4343vi . mock ( "./install.js" , ( ) => ( {
4444 installPluginFromNpmSpec : ( ...args : unknown [ ] ) => installPluginFromNpmSpecMock ( ...args ) ,
45- resolvePluginInstallDir : ( pluginId : string , extensionsDir = "/tmp" ) =>
46- `${ extensionsDir } /${ pluginId } ` ,
45+ resolvePluginInstallDir : ( pluginId : string , extensionsDir = "/tmp" ) => {
46+ const separator = process . platform === "win32" ? "\\" : "/" ;
47+ return `${ extensionsDir . replace ( / [ \\ / ] + $ / , "" ) } ${ separator } ${ pluginId } ` ;
48+ } ,
4749 PLUGIN_INSTALL_ERROR_CODE : {
4850 NPM_PACKAGE_NOT_FOUND : "npm_package_not_found" ,
4951 } ,
@@ -1079,6 +1081,45 @@ describe("updateNpmInstalledPlugins", () => {
10791081 ) ;
10801082 } ) ;
10811083
1084+ it ( "does not apply official beta-channel sync to third-party npm specs" , async ( ) => {
1085+ const installPath = createInstalledPackageDir ( {
1086+ name : "@martian-engineering/lossless-claw" ,
1087+ version : "0.9.0" ,
1088+ } ) ;
1089+ mockNpmViewMetadata ( {
1090+ name : "@martian-engineering/lossless-claw" ,
1091+ version : "0.9.1" ,
1092+ } ) ;
1093+ installPluginFromNpmSpecMock . mockResolvedValue (
1094+ createSuccessfulNpmUpdateResult ( {
1095+ pluginId : "lossless-claw" ,
1096+ targetDir : installPath ,
1097+ version : "0.9.1" ,
1098+ npmResolution : {
1099+ name : "@martian-engineering/lossless-claw" ,
1100+ version : "0.9.1" ,
1101+ resolvedSpec :
"@martian-engineering/[email protected] " , 1102+ } ,
1103+ } ) ,
1104+ ) ;
1105+
1106+ await updateNpmInstalledPlugins ( {
1107+ config : createNpmInstallConfig ( {
1108+ pluginId : "lossless-claw" ,
1109+ spec : "@martian-engineering/lossless-claw" ,
1110+ installPath,
1111+ resolvedName : "@martian-engineering/lossless-claw" ,
1112+ resolvedSpec :
"@martian-engineering/[email protected] " , 1113+ resolvedVersion : "0.9.0" ,
1114+ } ) ,
1115+ pluginIds : [ "lossless-claw" ] ,
1116+ syncOfficialPluginInstalls : true ,
1117+ officialPluginUpdateChannel : "beta" ,
1118+ } ) ;
1119+
1120+ expect ( npmInstallCall ( ) ?. spec ) . toBe ( "@martian-engineering/lossless-claw" ) ;
1121+ } ) ;
1122+
10821123 it ( "does not skip trusted official default updates when latest resolves to the installed prerelease" , async ( ) => {
10831124 const installPath = createInstalledPackageDir ( {
10841125 name : "@openclaw/acpx" ,
@@ -3906,10 +3947,11 @@ describe("updateNpmInstalledPlugins", () => {
39063947 pluginIds : [ "demo" ] ,
39073948 } ) ;
39083949
3909- expect ( npmInstallCall ( ) ?. extensionsDir ) . toBe ( extensionsDir ) ;
3910- expect ( clawHubInstallCall ( ) ?. extensionsDir ) . toBe ( extensionsDir ) ;
3911- expect ( marketplaceInstallCall ( ) ?. extensionsDir ) . toBe ( extensionsDir ) ;
3912- expect ( gitInstallCall ( ) ?. extensionsDir ) . toBe ( extensionsDir ) ;
3950+ const expectedExtensionsDir = path . resolve ( extensionsDir ) ;
3951+ expect ( npmInstallCall ( ) ?. extensionsDir ) . toBe ( expectedExtensionsDir ) ;
3952+ expect ( clawHubInstallCall ( ) ?. extensionsDir ) . toBe ( expectedExtensionsDir ) ;
3953+ expect ( marketplaceInstallCall ( ) ?. extensionsDir ) . toBe ( expectedExtensionsDir ) ;
3954+ expect ( gitInstallCall ( ) ?. extensionsDir ) . toBe ( expectedExtensionsDir ) ;
39133955 } ) ;
39143956} ) ;
39153957
0 commit comments