gkz / grasp

JavaScript structural search, replace, and refactor
http://graspjs.com
MIT License
1.28k stars 33 forks source link

Documentation is wrong for 'each' filter syntax #96

Closed nc-jenkins-deploy closed 8 years ago

nc-jenkins-deploy commented 8 years ago

The documentation on the 'each' filter says that: grasp arr --replace '[{{.elements | each before 1 | join "," }}]' will transform [1,2,3,4]; into [11,12,13,14];.

But when I run echo '[1,2,3,4];' | grasp arr --replace '[{{.elements | each before 1 | join "," }}]', I get: (standard input): Error during replacement. No arguments supplied for 'each before 1'.

I traced this back to levn.parse parsing the arguments 'before 1' into args = ['before 1'], rather than what it should be, which is args = ['before', 1].

Running echo '[1,2,3,4];' | grasp arr --replace '[{{.elements | each before, 1 | join "," }}]' (note the comma after 'before') produces the expected output.

ainthek commented 8 years ago

thanx, I have spent 40mins to figure this out....

PLEASE FIX THE DOCS

gkz commented 8 years ago

Sorry, the docs have been fixed, thanks for reporting.