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, )
| 68 | // It also updates the env by modifying the PathStack env-var, and the env-var |
| 69 | // for storing this path. |
| 70 | func (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 |
| 93 | func (s *stack) Has(projectHash string) bool { |