Allow calling direnv-cache from subdirectories of $DIRENV_DIR
This commit is contained in:
		
							parent
							
								
									0c8db23a3b
								
							
						
					
					
						commit
						6fb279eca0
					
				
							
								
								
									
										16
									
								
								direnv-cache
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								direnv-cache
									
									
									
									
									
								
							@ -70,9 +70,23 @@ getCacheFilePath() {
 | 
				
			|||||||
    echo "${cacheDir}/$(pwd | sha1sum | tr -d ' -')"
 | 
					    echo "${cacheDir}/$(pwd | sha1sum | tr -d ' -')"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					switchToDirenvDir() {
 | 
				
			||||||
 | 
					    # Find directory that contains the current .envrc.  Allows direnv-cache to
 | 
				
			||||||
 | 
					    # be called from subdirectories.
 | 
				
			||||||
 | 
					    wd="$(pwd)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if [[ -n $DIRENV_DIR ]]; then
 | 
				
			||||||
 | 
					        wd="${DIRENV_DIR#-}"
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    cd "$wd"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cmd="$1"
 | 
					cmd="$1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if ! [[ -e .envrc ]]; then
 | 
					switchToDirenvDir
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if ! [[ -e ".envrc" ]]; then
 | 
				
			||||||
    echo "Error, no .envrc found in current directory"
 | 
					    echo "Error, no .envrc found in current directory"
 | 
				
			||||||
    exit 1
 | 
					    exit 1
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user