@@ -2187,6 +2187,15 @@ function payloadFileSync(pointer) {
21872187 dlopen : process . dlopen ,
21882188 } ;
21892189
2190+ // Allow users to override the cache base directory via PKG_NATIVE_CACHE_PATH environment variable
2191+ // Default: path.join(homedir(), '.cache')
2192+ // - Linux/macOS: /home/john/.cache or /Users/john/.cache
2193+ // - Windows: C:\Users\John\.cache
2194+ // Custom example: /opt/myapp/cache or C:\myapp\cache
2195+ // Native addons will be extracted to: <PKG_NATIVE_CACHE_BASE>/pkg/<hash>
2196+ const PKG_NATIVE_CACHE_BASE =
2197+ process . env . PKG_NATIVE_CACHE_PATH || path . join ( homedir ( ) , '.cache' ) ;
2198+
21902199 function revertMakingLong ( f ) {
21912200 if ( / ^ \\ \\ \? \\ / . test ( f ) ) return f . slice ( 4 ) ;
21922201 return f ;
@@ -2206,11 +2215,7 @@ function payloadFileSync(pointer) {
22062215 // the hash is needed to be sure we reload the module in case it changes
22072216 const hash = createHash ( 'sha256' ) . update ( moduleContent ) . digest ( 'hex' ) ;
22082217
2209- // Allow users to override the cache directory via PKG_NATIVE_CACHE_PATH environment variable
2210- // Example: /home/john/.cache/pkg/<hash> or custom path like /opt/myapp/cache/pkg/<hash>
2211- const cacheBase =
2212- process . env . PKG_NATIVE_CACHE_PATH || path . join ( homedir ( ) , '.cache' ) ;
2213- const tmpFolder = path . join ( cacheBase , 'pkg' , hash ) ;
2218+ const tmpFolder = path . join ( PKG_NATIVE_CACHE_BASE , 'pkg' , hash ) ;
22142219
22152220 fs . mkdirSync ( tmpFolder , { recursive : true } ) ;
22162221
0 commit comments