@@ -4,6 +4,7 @@ use std::fmt::{Display, Formatter};
44use std:: io:: Write ;
55use std:: path:: { Path , PathBuf } ;
66
7+ use crate :: env:: PATH_KEY ;
78use base64:: prelude:: * ;
89use eyre:: Result ;
910use flate2:: write:: { ZlibDecoder , ZlibEncoder } ;
@@ -33,15 +34,15 @@ impl DirenvDiff {
3334 }
3435
3536 pub fn new_path ( & self ) -> Vec < PathBuf > {
36- let path = self . new . get ( "PATH" ) ;
37+ let path = self . new . get ( & * PATH_KEY ) ;
3738 match path {
3839 Some ( path) => split_paths ( path) . collect ( ) ,
3940 None => vec ! [ ] ,
4041 }
4142 }
4243
4344 pub fn old_path ( & self ) -> Vec < PathBuf > {
44- let path = self . old . get ( "PATH" ) ;
45+ let path = self . old . get ( & * PATH_KEY ) ;
4546 match path {
4647 Some ( path) => split_paths ( path) . collect ( ) ,
4748 None => vec ! [ ] ,
@@ -59,10 +60,14 @@ impl DirenvDiff {
5960 old. insert ( 0 , path. into ( ) ) ;
6061 new. insert ( 0 , path. into ( ) ) ;
6162
62- self . old
63- . insert ( "PATH" . into ( ) , join_paths ( & old) ?. into_string ( ) . unwrap ( ) ) ;
64- self . new
65- . insert ( "PATH" . into ( ) , join_paths ( & new) ?. into_string ( ) . unwrap ( ) ) ;
63+ self . old . insert (
64+ PATH_KEY . to_string ( ) ,
65+ join_paths ( & old) ?. into_string ( ) . unwrap ( ) ,
66+ ) ;
67+ self . new . insert (
68+ PATH_KEY . to_string ( ) ,
69+ join_paths ( & new) ?. into_string ( ) . unwrap ( ) ,
70+ ) ;
6671
6772 Ok ( ( old, new) )
6873 }
@@ -78,10 +83,14 @@ impl DirenvDiff {
7883 old. iter ( ) . position ( |p| p == path) . map ( |i| old. remove ( i) ) ;
7984 new. iter ( ) . position ( |p| p == path) . map ( |i| new. remove ( i) ) ;
8085
81- self . old
82- . insert ( "PATH" . into ( ) , join_paths ( & old) ?. into_string ( ) . unwrap ( ) ) ;
83- self . new
84- . insert ( "PATH" . into ( ) , join_paths ( & new) ?. into_string ( ) . unwrap ( ) ) ;
86+ self . old . insert (
87+ PATH_KEY . to_string ( ) ,
88+ join_paths ( & old) ?. into_string ( ) . unwrap ( ) ,
89+ ) ;
90+ self . new . insert (
91+ PATH_KEY . to_string ( ) ,
92+ join_paths ( & new) ?. into_string ( ) . unwrap ( ) ,
93+ ) ;
8594
8695 Ok ( ( old, new) )
8796 }
0 commit comments