Append unique parameter not working
I just started using plop this week and was trying to insert a value from a prompt into an array, but not have duplicate values. I thought the unique property for the append action would remove all duplicates, but it doesn't seem to be working.
Here is a minimal repo to reproduce this issue.
+1 unique does not work (duplicated entries in dest file after append action)
fixed in v2.5.1
This works now but something is still not working as I expect.
hbs file with the below content is always rendered regardless of unique setting. This is something I do not expect.
A STRING TO APPEND /* a comment to add */
This one works fine.
A STRING TO APPEND
The problem seems to be the block comment at the end of the line, I use them to track code appends, who did this etc. I do not modify the block comment with plop tokens they stay always the same.
The below single line comment works fine with append
A STRING TO APPEND // a comment to add
I am at 2.5.3
The above seems to be related to the regular expression which checks for duplicates/unique values. for example the below string in a hbs file fails to append. This string is a valid tsx/jsx comment
{/* <Route key="AboutPage" exact path={PATHS.ABOUT_PAGE} render={(pr */}
× _+ Invalid regular expression: /
{/* <Route key="AboutPage" exact path={PATHS.ABOUT_PAGE} render={(pr */}/: Unterminated group
Done in 1.39s.
Sorry to flood you but I found some more things, the problem is with the brackets around "(props)", it makes the regex fail to find the inserted string. "(" and ")" should be escaped while searching. maybe there are also other chars to be escaped.
Since I use ts/tsx braces are needed with types like (props : string) etc
<Route key="AboutPage" exact path={PATHS.ABOUT_PAGE} render={(props) => <AboutPage {...props} />} />
+1
I'm running the same issue here. I'm trying to use an asterik in my templete and the unique just falied:
export * as {{pascalCase name}} from '../services/{{dashCase name}}/types/events';
I alse tried using a helper, but the result is the same:
export {{asterisk}} as {{pascalCase name}} from '../services/{{dashCase name}}/types/events';