16 lines
394 B
Go
16 lines
394 B
Go
package mcp
|
|
|
|
import "path/filepath"
|
|
|
|
// NpmCacheEnv returns env vars pointing npx's package cache at cacheDir. Empty
|
|
// unless command's base name is npx and cacheDir is set.
|
|
func NpmCacheEnv(command, cacheDir string) []string {
|
|
if filepath.Base(command) != "npx" || cacheDir == "" {
|
|
return nil
|
|
}
|
|
return []string{
|
|
"NPM_CONFIG_CACHE=" + cacheDir,
|
|
"NPM_CONFIG_PREFER_OFFLINE=true",
|
|
}
|
|
}
|