File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed
Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -1119,4 +1119,30 @@ describe('Resource parameter tests', () => {
11191119 propB : 'random2' ,
11201120 } ) ) . to . be . false ;
11211121 } )
1122+
1123+ it ( 'Can match directories 1' , async ( ) => {
1124+ const resource = new class extends TestResource {
1125+ getSettings ( ) : ResourceSettings < TestConfig > {
1126+ return {
1127+ id : 'resourceType' ,
1128+ parameterSettings : {
1129+ propA : { type : 'directory' }
1130+ } ,
1131+ }
1132+ }
1133+ } ;
1134+
1135+ const controller = new ResourceController ( resource ) ;
1136+ const transformations = controller . parsedSettings . inputTransformations . propA ;
1137+
1138+ const to = transformations ! . to ( '$HOME/abc/def' )
1139+ expect ( to ) . to . eq ( os . homedir ( ) + '/abc/def' )
1140+
1141+ const from = transformations ! . from ( os . homedir ( ) + '/abc/def' )
1142+ expect ( from ) . to . eq ( '~/abc/def' )
1143+
1144+ const from2 = transformations ! . from ( os . homedir ( ) + '/abc/def' , '$HOME/abc/def' )
1145+ expect ( from2 ) . to . eq ( '$HOME/abc/def' )
1146+
1147+ } )
11221148} )
Original file line number Diff line number Diff line change @@ -313,9 +313,22 @@ export interface StatefulParameterSetting extends DefaultParameterSetting {
313313const ParameterEqualsDefaults : Partial < Record < ParameterSettingType , ( a : unknown , b : unknown ) => boolean > > = {
314314 'boolean' : ( a : unknown , b : unknown ) => Boolean ( a ) === Boolean ( b ) ,
315315 'directory' : ( a : unknown , b : unknown ) => {
316+ let transformedA = resolvePathWithVariables ( untildify ( String ( a ) ) )
317+ let transformedB = resolvePathWithVariables ( untildify ( String ( b ) ) )
318+
319+ if ( transformedA . startsWith ( '.' ) ) { // Only relative paths start with '.'
320+ transformedA = path . resolve ( transformedA )
321+ }
322+
323+ if ( transformedB . startsWith ( '.' ) ) { // Only relative paths start with '.'
324+ transformedB = path . resolve ( transformedB )
325+ }
326+
316327 const notCaseSensitive = process . platform === 'darwin' ;
317- const transformedA = path . resolve ( resolvePathWithVariables ( untildify ( notCaseSensitive ? String ( a ) . toLowerCase ( ) : String ( a ) ) ) )
318- const transformedB = path . resolve ( resolvePathWithVariables ( untildify ( notCaseSensitive ? String ( b ) . toLowerCase ( ) : String ( b ) ) ) )
328+ if ( notCaseSensitive ) {
329+ transformedA = transformedA . toLowerCase ( ) ;
330+ transformedB = transformedB . toLowerCase ( ) ;
331+ }
319332
320333 return transformedA === transformedB ;
321334 } ,
You can’t perform that action at this time.
0 commit comments