Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Paths shouldn't be validated when the condition evaluates to false #342
Scenario: I want to create a path for a new module. If the user answers 'yes' to the question of whether or not to create a Git top level folder, they receive an additional prompt for a 'GitRepoName' and that name is used to create an additional top level folder that the module folder is a sub-folder of.
Parameters: Name, Git, GitRepoName
If Git = Yes, then the folder structure should look like this:
If Git = No, then it should like like this:
The problem is that a condition that evaluates to false still validates the path specified in that line of the manifest.
Sample PlasterTemplate.xml file
Sample code to generate the folder structure:
The following error is generated when 'Git' is set to 'No':
This is due to the path in the following line being validated even when the condition evaluates to false:
The problem can be worked around by prompting the user for a 'GitRepoName' even when it's not used, but this shouldn't be required.
Line 1067 of the
This logic is flawed as the path may not be valid if the condition evaluates to false based on how the template is created as is the case in my scenario.
Seems like a reasonable request and an easy change to make - just move these lines:
above the comment line you referred to. If you don't have time to submit a PR, I can make the change but if you want to tackle this, that'd be great.
referenced this issue
Aug 23, 2018
I ran the debugger on the code before and after the change to see what happens. I see moving it prior to the comment as recommended causes the code to hit the return statement before the error would occur when the condition is false, although it does still seem to do a lot even when a condition is false before it gets to that point.
I've submitted the recommended changes and changed the comment in the code to reflect the new logic.