Using codemods 3 -> 4

I am upgrading my projects to canjs 4 and when I run can-migrate --apply **/*.js --can-version 4 I get what appears to be “help” output:

When I run can-migrate **/*.* --can-version 4 as shown as an example in the “help” output I receive the following:

Is there something that I am missing? Should I be running from a particular folder perhaps?

Eben,

Can you tell me what version of can-migrate you are using with can-migrate --version ?

I installed the new one as per the ‘Migrating to CanJS 4’ guide: npm install -g can-migrate@2

Eben,

Can you make sure the your working directory is clean by checking all your changes and then doing a commit before running the can-migrate command?

I am unable to reproduce your issue currently, but it looks like you are using Windows. Switching over to Windows now to see if I can reproduce.

Eben,

Please run this with the apply after the file glob like:
can-migrate **/*.js --can-version 4 --apply

Not sure why this makes a difference but I am looking into it.

Thanks John,

That did the trick! Quite odd about the commit. Probably worthwhile updating the docs with this information.

However, some of the changes have some unintended consequences. For example:

image

The original value in the get method really should not have changed. I’m guessing some serious static analysis would be required to get this 100% correct so I’ll just revert those bits that had more “unintended consequences” than fixes. :slight_smile:

Hey @eben_roux, thanks for pointing out the faulty value => default logic. We might be able to fix this (codemods are pretty amazing in what they can parse from code). I filed an issue: https://github.com/canjs/can-migrate/issues/77

I double checked and this was fixed already in can-migrate@2.0.0. Sorry for giving you bad information earlier, @chasen.