@@ -99,14 +99,61 @@ suite('ProcessLogger suite', () => {
9999 ) ;
100100 } ) ;
101101
102- test ( 'Logger replaces the path/to/home with ~ in the command path' , async ( ) => {
102+ test ( 'Logger replaces the path/to/home with ~ in the command path where the home path IS at the beginning of the path ' , async ( ) => {
103103 const options = { cwd : path . join ( 'debug' , 'path' ) } ;
104104 logger . logProcess ( path . join ( untildify ( '~' ) , 'test' ) , [ '--foo' , '--bar' ] , options ) ;
105105
106106 sinon . assert . calledWithExactly ( traceLogStub , `> ${ path . join ( '~' , 'test' ) } --foo --bar` ) ;
107107 sinon . assert . calledWithExactly ( traceLogStub , `${ Logging . currentWorkingDirectory } ${ options . cwd } ` ) ;
108108 } ) ;
109109
110+ test ( 'Logger replaces the path/to/home with ~ in the command path where the home path IS at the beginning of the path but another arg contains other ref to home folder' , async ( ) => {
111+ const options = { cwd : path . join ( 'debug' , 'path' ) } ;
112+ logger . logProcess ( path . join ( untildify ( '~' ) , 'test' ) , [ '--foo' , path . join ( untildify ( '~' ) , 'boo' ) ] , options ) ;
113+
114+ sinon . assert . calledWithExactly ( traceLogStub , `> ${ path . join ( '~' , 'test' ) } --foo ${ path . join ( '~' , 'boo' ) } ` ) ;
115+ sinon . assert . calledWithExactly ( traceLogStub , `${ Logging . currentWorkingDirectory } ${ options . cwd } ` ) ;
116+ } ) ;
117+
118+ test ( 'Logger replaces the path/to/home with ~ in the command path where the home path IS at the beginning of the path between doble quotes' , async ( ) => {
119+ const options = { cwd : path . join ( 'debug' , 'path' ) } ;
120+ logger . logProcess ( `"${ path . join ( untildify ( '~' ) , 'test' ) } " "--foo" "--bar"` , undefined , options ) ;
121+
122+ sinon . assert . calledWithExactly ( traceLogStub , `> "${ path . join ( '~' , 'test' ) } " "--foo" "--bar"` ) ;
123+ sinon . assert . calledWithExactly ( traceLogStub , `${ Logging . currentWorkingDirectory } ${ options . cwd } ` ) ;
124+ } ) ;
125+
126+ test ( 'Logger replaces the path/to/home with ~ in the command path where the home path IS NOT at the beginning of the path' , async ( ) => {
127+ const options = { cwd : path . join ( 'debug' , 'path' ) } ;
128+ logger . logProcess ( path . join ( 'net' , untildify ( '~' ) , 'test' ) , [ '--foo' , '--bar' ] , options ) ;
129+
130+ sinon . assert . calledWithExactly ( traceLogStub , `> ${ path . join ( 'net' , '~' , 'test' ) } --foo --bar` ) ;
131+ sinon . assert . calledWithExactly ( traceLogStub , `${ Logging . currentWorkingDirectory } ${ options . cwd } ` ) ;
132+ } ) ;
133+
134+ test ( 'Logger replaces the path/to/home with ~ in the command path where the home path IS NOT at the beginning of the path but another arg contains other ref to home folder' , async ( ) => {
135+ const options = { cwd : path . join ( 'debug' , 'path' ) } ;
136+ logger . logProcess (
137+ path . join ( 'net' , untildify ( '~' ) , 'test' ) ,
138+ [ '--foo' , path . join ( untildify ( '~' ) , 'boo' ) ] ,
139+ options ,
140+ ) ;
141+
142+ sinon . assert . calledWithExactly (
143+ traceLogStub ,
144+ `> ${ path . join ( 'net' , '~' , 'test' ) } --foo ${ path . join ( '~' , 'boo' ) } ` ,
145+ ) ;
146+ sinon . assert . calledWithExactly ( traceLogStub , `${ Logging . currentWorkingDirectory } ${ options . cwd } ` ) ;
147+ } ) ;
148+
149+ test ( 'Logger replaces the path/to/home with ~ in the command path where the home path IS NOT at the beginning of the path between doble quotes' , async ( ) => {
150+ const options = { cwd : path . join ( 'debug' , 'path' ) } ;
151+ logger . logProcess ( `"${ path . join ( 'net' , untildify ( '~' ) , 'test' ) } " "--foo" "--bar"` , undefined , options ) ;
152+
153+ sinon . assert . calledWithExactly ( traceLogStub , `> "${ path . join ( 'net' , '~' , 'test' ) } " "--foo" "--bar"` ) ;
154+ sinon . assert . calledWithExactly ( traceLogStub , `${ Logging . currentWorkingDirectory } ${ options . cwd } ` ) ;
155+ } ) ;
156+
110157 test ( 'Logger replaces the path/to/home with ~ if shell command is provided' , async ( ) => {
111158 const options = { cwd : path . join ( 'debug' , 'path' ) } ;
112159 logger . logProcess ( `"${ path . join ( untildify ( '~' ) , 'test' ) } " "--foo" "--bar"` , undefined , options ) ;
0 commit comments