plop icon indicating copy to clipboard operation
plop copied to clipboard

Append unique parameter not working

Open kotojo opened this issue 7 years ago • 6 comments

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.

kotojo avatar Sep 12 '19 13:09 kotojo

+1 unique does not work (duplicated entries in dest file after append action)

maryiam avatar Oct 18 '19 09:10 maryiam

fixed in v2.5.1

amwmedia avatar Oct 18 '19 17:10 amwmedia

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

cemcakirlar avatar Nov 24 '19 19:11 cemcakirlar

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.

cemcakirlar avatar Nov 24 '19 19:11 cemcakirlar

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} />} />

cemcakirlar avatar Nov 24 '19 19:11 cemcakirlar

+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';

andres-sinapsis avatar Apr 30 '21 14:04 andres-sinapsis