File tree 3 files changed +26
-1
lines changed
3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,9 @@ pub(crate) fn load_dotenv(
24
24
}
25
25
26
26
if let Some ( path) = dotenv_path {
27
+ let path = working_directory. join ( path) ;
27
28
if path. is_file ( ) {
28
- return load_from_file ( & working_directory . join ( path) ) ;
29
+ return load_from_file ( & path) ;
29
30
}
30
31
}
31
32
Original file line number Diff line number Diff line change @@ -360,6 +360,7 @@ fn no_dotenv() {
360
360
. stderr ( "echo DEFAULT\n " )
361
361
. run ( ) ;
362
362
}
363
+
363
364
#[ test]
364
365
fn dotenv_env_var_override ( ) {
365
366
Test :: new ( )
@@ -375,3 +376,21 @@ fn dotenv_env_var_override() {
375
376
. stderr ( "echo $DOTENV_KEY\n " )
376
377
. run ( ) ;
377
378
}
379
+
380
+ #[ test]
381
+ fn dotenv_path_usable_from_subdir ( ) {
382
+ Test :: new ( )
383
+ . justfile (
384
+ "
385
+ set dotenv-path := '.custom-env'
386
+
387
+ @echo:
388
+ echo $DOTENV_KEY
389
+ " ,
390
+ )
391
+ . create_dir ( "sub" )
392
+ . current_dir ( "sub" )
393
+ . write ( ".custom-env" , "DOTENV_KEY=dotenv-value" )
394
+ . stdout ( "dotenv-value\n " )
395
+ . run ( ) ;
396
+ }
Original file line number Diff line number Diff line change @@ -94,6 +94,11 @@ impl Test {
94
94
self
95
95
}
96
96
97
+ pub ( crate ) fn create_dir ( self , path : impl AsRef < Path > ) -> Self {
98
+ fs:: create_dir_all ( self . tempdir . path ( ) . join ( path. as_ref ( ) ) ) . unwrap ( ) ;
99
+ self
100
+ }
101
+
97
102
pub ( crate ) fn current_dir ( mut self , path : impl AsRef < Path > ) -> Self {
98
103
path. as_ref ( ) . clone_into ( & mut self . current_dir ) ;
99
104
self
You can’t perform that action at this time.
0 commit comments