@@ -109,32 +109,55 @@ suite('ProcessLogger suite', () => {
109109
110110 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 ( ) => {
111111 const options = { cwd : path . join ( 'debug' , 'path' ) } ;
112- logger . logProcess ( path . join ( 'net' , untildify ( '~' ) , 'test' ) , [ '--foo' , '--bar' ] , options ) ;
112+ const untildifyStr = untildify ( '~' ) ;
113+
114+ let p1 = path . join ( 'net' , untildifyStr , 'test' ) ;
115+ if ( p1 . startsWith ( '.' ) ) {
116+ if ( getOSType ( ) === OSType . Windows ) {
117+ p1 = p1 . replace ( / ^ \. \\ + / , '' ) ;
118+ } else {
119+ p1 = p1 . replace ( / ^ \. \\ / , '' ) ;
120+ }
121+ }
122+ logger . logProcess ( p1 , [ '--foo' , '--bar' ] , options ) ;
113123
114- sinon . assert . calledWithExactly ( traceLogStub , `> ${ path . join ( 'net' , '~' , 'test' ) } --foo --bar` ) ;
124+ const path1 = path . join ( '.' , 'net' , '~' , 'test' ) ;
125+ sinon . assert . calledWithExactly ( traceLogStub , `> ${ path1 } --foo --bar` ) ;
115126 sinon . assert . calledWithExactly ( traceLogStub , `cwd: ${ options . cwd } ` ) ;
116127 } ) ;
117128
118129 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 ( ) => {
119130 const options = { cwd : path . join ( 'debug' , 'path' ) } ;
120- logger . logProcess (
121- path . join ( 'net' , untildify ( '~' ) , 'test' ) ,
122- [ '--foo' , path . join ( untildify ( '~' ) , 'boo' ) ] ,
123- options ,
124- ) ;
131+ let p1 = path . join ( 'net' , untildify ( '~' ) , 'test' ) ;
132+ if ( p1 . startsWith ( '.' ) ) {
133+ if ( getOSType ( ) === OSType . Windows ) {
134+ p1 = p1 . replace ( / ^ \. \\ + / , '' ) ;
135+ } else {
136+ p1 = p1 . replace ( / ^ \. \\ / , '' ) ;
137+ }
138+ }
139+ logger . logProcess ( p1 , [ '--foo' , path . join ( untildify ( '~' ) , 'boo' ) ] , options ) ;
125140
126141 sinon . assert . calledWithExactly (
127142 traceLogStub ,
128- `> ${ path . join ( 'net' , '~' , 'test' ) } --foo ${ path . join ( '~' , 'boo' ) } ` ,
143+ `> ${ path . join ( '.' , ' net', '~' , 'test' ) } --foo ${ path . join ( '~' , 'boo' ) } ` ,
129144 ) ;
130145 sinon . assert . calledWithExactly ( traceLogStub , `cwd: ${ options . cwd } ` ) ;
131146 } ) ;
132147
133148 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 ( ) => {
134149 const options = { cwd : path . join ( 'debug' , 'path' ) } ;
135- logger . logProcess ( `"${ path . join ( 'net' , untildify ( '~' ) , 'test' ) } " "--foo" "--bar"` , undefined , options ) ;
150+ let p1 = path . join ( 'net' , untildify ( '~' ) , 'test' ) ;
151+ if ( p1 . startsWith ( '.' ) ) {
152+ if ( getOSType ( ) === OSType . Windows ) {
153+ p1 = p1 . replace ( / ^ \. \\ + / , '' ) ;
154+ } else {
155+ p1 = p1 . replace ( / ^ \. \\ / , '' ) ;
156+ }
157+ }
158+ logger . logProcess ( `"${ p1 } " "--foo" "--bar"` , undefined , options ) ;
136159
137- sinon . assert . calledWithExactly ( traceLogStub , `> "${ path . join ( 'net' , '~' , 'test' ) } " "--foo" "--bar"` ) ;
160+ sinon . assert . calledWithExactly ( traceLogStub , `> "${ path . join ( '.' , ' net', '~' , 'test' ) } " "--foo" "--bar"` ) ;
138161 sinon . assert . calledWithExactly ( traceLogStub , `cwd: ${ options . cwd } ` ) ;
139162 } ) ;
140163
0 commit comments