Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jscodeshift.registerMethods should be idempotent #22

Closed
aaronjensen opened this issue Aug 18, 2015 · 3 comments
Closed

jscodeshift.registerMethods should be idempotent #22

aaronjensen opened this issue Aug 18, 2015 · 3 comments

Comments

@aaronjensen
Copy link

If I include a jscodeshift.registerMethods in my transform, it works the first time, but if I change the transform, I get an error:

A method with name "findReturnsInCurrentScope" already exists.

I'd expect a fresh jscodeshift w/ no methods registered each iteration.

Repro: http://felix-kling.de/esprima_ast_explorer/#/NvHouJt2GJ

Just open it, and make a change to the transform.

@fkling
Copy link
Owner

fkling commented Aug 18, 2015

Thanks for pointing that out! Not sure how to get a fresh copy since that's not how modules work, but maybe we can expose some API to clear the registered methods.

@aaronjensen
Copy link
Author

yeah, if it's not running in an iframe it's tough. If the result runs in an iframe then you could just load it anew every time.

Otherwise, either a clear api or a "i know i'm overwriting methods" option to registerMethods would work.

RReverser added a commit to RReverser/esprima_ast_explorer that referenced this issue Dec 11, 2015
Added a hack to prevent errors on jscodeshift.registerMethods when
editing, while still throwing on duplicates within same run.
@aaronjensen
Copy link
Author

Thanks @RReverser and @fkling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants