MCPcopy Index your code
hub / github.com/jetify-com/devbox / Push

Method Push

internal/devbox/envpath/stack.go:70–90  ·  view source on GitHub ↗

Push adds the new PATH for the devbox-project identified by projectHash. This PATH is pushed to the top of the stack (given highest priority), unless preservePathStack is enabled. It also updates the env by modifying the PathStack env-var, and the env-var for storing this path.

(
	env map[string]string,
	projectHash string,
	path string, // new PATH of the devbox-project of projectHash
	preservePathStack bool,
)

Source from the content-addressed store, hash-verified

68// It also updates the env by modifying the PathStack env-var, and the env-var
69// for storing this path.
70func (s *stack) Push(
71 env map[string]string,
72 projectHash string,
73 path string, // new PATH of the devbox-project of projectHash
74 preservePathStack bool,
75) {
76 key := Key(projectHash)
77
78 // Add this path to env
79 env[key] = path
80
81 // Common case: ensure this key is at the top of the stack
82 if !preservePathStack ||
83 // Case preservePathStack == true, usually from bin-wrapper or (in future) shell hook.
84 // Add this key only if absent from the stack
85 !lo.Contains(s.keys, key) {
86
87 s.keys = lo.Uniq(slices.Insert(s.keys, 0, key))
88 }
89 env[PathStackEnv] = s.String()
90}
91
92// Has tests if the stack has the key corresponding to projectHash
93func (s *stack) Has(projectHash string) bool {

Callers 1

TestNewStackFunction · 0.45

Calls 2

StringMethod · 0.95
KeyFunction · 0.85

Tested by 1

TestNewStackFunction · 0.36