11import fs from "node:fs" ;
2- import os from "node:os" ;
32import path from "node:path" ;
43import { describe , expect , it } from "vitest" ;
4+ import { resolvePreferredOpenClawTmpDir } from "../../../../infra/tmp-openclaw-dir.js" ;
55import { listChannelPluginCatalogEntries } from "../../catalog.js" ;
66
77function createCatalogEntry ( params : {
@@ -122,7 +122,9 @@ export function describeChannelPluginCatalogEntriesContract() {
122122 {
123123 name : "includes external catalog entries" ,
124124 setup : ( ) => {
125- const dir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "openclaw-catalog-" ) ) ;
125+ const dir = fs . mkdtempSync (
126+ path . join ( resolvePreferredOpenClawTmpDir ( ) , "openclaw-catalog-" ) ,
127+ ) ;
126128 const catalogPath = path . join ( dir , "catalog.json" ) ;
127129 writeCatalogFile (
128130 catalogPath ,
@@ -145,7 +147,7 @@ export function describeChannelPluginCatalogEntriesContract() {
145147 name : "preserves plugin ids when they differ from channel ids" ,
146148 setup : ( ) => {
147149 const stateDir = fs . mkdtempSync (
148- path . join ( os . tmpdir ( ) , "openclaw-channel-catalog-state-" ) ,
150+ path . join ( resolvePreferredOpenClawTmpDir ( ) , "openclaw-channel-catalog-state-" ) ,
149151 ) ;
150152 writeDiscoveredChannelPlugin ( {
151153 stateDir,
@@ -168,7 +170,9 @@ export function describeChannelPluginCatalogEntriesContract() {
168170 {
169171 name : "keeps discovered plugins ahead of external catalog overrides" ,
170172 setup : ( ) => {
171- const stateDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "openclaw-catalog-state-" ) ) ;
173+ const stateDir = fs . mkdtempSync (
174+ path . join ( resolvePreferredOpenClawTmpDir ( ) , "openclaw-catalog-state-" ) ,
175+ ) ;
172176 const catalogPath = path . join ( stateDir , "catalog.json" ) ;
173177 writeDiscoveredChannelPlugin ( {
174178 stateDir,
@@ -206,7 +210,9 @@ export function describeChannelPluginCatalogEntriesContract() {
206210 {
207211 name : "accepts rich external manifest entries with pinned npm metadata" ,
208212 setup : ( ) => {
209- const dir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "openclaw-catalog-rich-" ) ) ;
213+ const dir = fs . mkdtempSync (
214+ path . join ( resolvePreferredOpenClawTmpDir ( ) , "openclaw-catalog-rich-" ) ,
215+ ) ;
210216 const catalogPath = path . join ( dir , "catalog.json" ) ;
211217 fs . writeFileSync (
212218 catalogPath ,
@@ -284,7 +290,9 @@ export function describeChannelPluginCatalogEntriesContract() {
284290 {
285291 name : "accepts rich external manifest entries for yuanbao with pinned npm metadata" ,
286292 setup : ( ) => {
287- const dir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "openclaw-catalog-yuanbao-" ) ) ;
293+ const dir = fs . mkdtempSync (
294+ path . join ( resolvePreferredOpenClawTmpDir ( ) , "openclaw-catalog-yuanbao-" ) ,
295+ ) ;
288296 const catalogPath = path . join ( dir , "catalog.json" ) ;
289297 fs . writeFileSync (
290298 catalogPath ,
@@ -365,7 +373,9 @@ export function describeChannelPluginCatalogPathResolutionContract() {
365373 {
366374 name : "uses the provided env for external catalog path resolution" ,
367375 setup : ( ) => {
368- const home = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "openclaw-catalog-home-" ) ) ;
376+ const home = fs . mkdtempSync (
377+ path . join ( resolvePreferredOpenClawTmpDir ( ) , "openclaw-catalog-home-" ) ,
378+ ) ;
369379 const catalogPath = path . join ( home , "catalog.json" ) ;
370380 writeCatalogFile (
371381 catalogPath ,
@@ -391,7 +401,9 @@ export function describeChannelPluginCatalogPathResolutionContract() {
391401 {
392402 name : "uses the provided env for default catalog paths" ,
393403 setup : ( ) => {
394- const stateDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "openclaw-catalog-state-" ) ) ;
404+ const stateDir = fs . mkdtempSync (
405+ path . join ( resolvePreferredOpenClawTmpDir ( ) , "openclaw-catalog-state-" ) ,
406+ ) ;
395407 const catalogPath = path . join ( stateDir , "plugins" , "catalog.json" ) ;
396408 fs . mkdirSync ( path . dirname ( catalogPath ) , { recursive : true } ) ;
397409 writeCatalogFile (
0 commit comments