@@ -132,6 +132,36 @@ describe('appstash', () => {
132132 } ) ;
133133 } ) ;
134134
135+ describe ( 'APPSTASH_BASE_DIR env var' , ( ) => {
136+ const originalEnv = process . env . APPSTASH_BASE_DIR ;
137+
138+ afterEach ( ( ) => {
139+ if ( originalEnv === undefined ) {
140+ delete process . env . APPSTASH_BASE_DIR ;
141+ } else {
142+ process . env . APPSTASH_BASE_DIR = originalEnv ;
143+ }
144+ } ) ;
145+
146+ it ( 'should use APPSTASH_BASE_DIR when no baseDir option is provided' , ( ) => {
147+ process . env . APPSTASH_BASE_DIR = tempBase ;
148+ const dirs = appstash ( 'pgpm' ) ;
149+
150+ expect ( dirs . root ) . toBe ( path . join ( tempBase , '.pgpm' ) ) ;
151+ expect ( dirs . config ) . toBe ( path . join ( tempBase , '.pgpm' , 'config' ) ) ;
152+ } ) ;
153+
154+ it ( 'should prefer baseDir option over APPSTASH_BASE_DIR env var' , ( ) => {
155+ const otherBase = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'appstash-other-' ) ) ;
156+ process . env . APPSTASH_BASE_DIR = otherBase ;
157+
158+ const dirs = appstash ( 'pgpm' , { baseDir : tempBase } ) ;
159+
160+ expect ( dirs . root ) . toBe ( path . join ( tempBase , '.pgpm' ) ) ;
161+ fs . rmSync ( otherBase , { recursive : true , force : true } ) ;
162+ } ) ;
163+ } ) ;
164+
135165 describe ( 'Edge cases' , ( ) => {
136166 it ( 'should handle tool names with special characters' , ( ) => {
137167 const dirs = appstash ( 'my-app' , { baseDir : tempBase } ) ;
0 commit comments