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

Compatibility with ember-template-recast v5 #155

Closed
simonihmig opened this issue Feb 2, 2021 · 3 comments · Fixed by #156
Closed

Compatibility with ember-template-recast v5 #155

simonihmig opened this issue Feb 2, 2021 · 3 comments · Fixed by #156

Comments

@simonihmig
Copy link
Contributor

We need to update ember-template-recast to v5, which seems to have some breaking changes. See #138

Making things worse, when running a codemod with npx within a project that already has v5 in its node_modules, node will take this version instead, which breaks the codemod with Cannot destructure property 'parse' of 'undefined' as it is undefined.. (Same as the dependabot PR's CI failure: https://github.com/rwjblue/codemod-cli/pull/138/checks?check_run_id=1807589103#step:5:138)

@rwjblue
Copy link
Owner

rwjblue commented Feb 2, 2021

Making things worse, when running a codemod with npx within a project that already has v5 in its node_modules, node will take this version instead, which breaks the codemod with Cannot destructure property 'parse' of 'undefined' as it is undefined.

We can fix the error by changing this:

return execa('ember-template-recast', binOptions, {
stdio: 'inherit',
preferLocal: true,
env: {
CODEMOD_CLI_ARGS: JSON.stringify(options),
},
});

To:

 let templateRecastBinPath = path.join(
   path.dirname(require.resolve('ember-template-recast/package'),
   'lib',
   'bin.js'
 );
 return execa(templateRecastBinPath, ', binOptions, { 
   stdio: 'inherit', 
   env: { 
     CODEMOD_CLI_ARGS: JSON.stringify(options), 
   }, 
 }); 

@rajasegar-c
Copy link
Contributor

rajasegar-c commented May 21, 2021

@rwjblue Did we cut a release with the PR changes , I am still getting the error mentioned in #161
Also the ember-template-recast version is still 4.x

@rwjblue
Copy link
Owner

rwjblue commented Jan 13, 2022

Actually, I just figured out what you ran into here. Checkout my comment in e57cd1a (#201) for details.

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