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

Unexpected error #10

Closed
cowboy opened this issue Oct 5, 2021 · 4 comments
Closed

Unexpected error #10

cowboy opened this issue Oct 5, 2021 · 4 comments

Comments

@cowboy
Copy link

cowboy commented Oct 5, 2021

I'm using 2.0.0-beta.5. If I have this file.js

module.exports = () => {
  return global.rules.find(
    (rule) =>
      typeof rule.loader === 'string' && /babel-loader/.test(rule.loader)
  )
}

And run this bash script

#!/usr/bin/env bash

read -r -d '' find <<'EOF'
module.exports = () => {
  $$functionBody
}
EOF

read -r -d '' replace <<'EOF'
module.exports = {
  fn() {
    $$functionBody
  }
}
EOF

astx -y -f "$find" -r "$replace" file.js

I get this error

==========================================
file.js
==========================================
TypeError: Cannot read property 'raw' of undefined
    at genericPrintNoParens (/path/to/astx/lib/node_modules/astx/node_modules/recast/lib/printer.js:677:47)
    at genericPrint (/path/to/astx/lib/node_modules/astx/node_modules/recast/lib/printer.js:123:30)
    at print (/path/to/astx/lib/node_modules/astx/node_modules/recast/lib/printer.js:77:15)
    at /path/to/astx/lib/node_modules/astx/node_modules/recast/lib/printer.js:49:41
    at Object.printComments (/path/to/astx/lib/node_modules/astx/node_modules/recast/lib/comments.js:281:22)
    at print (/path/to/astx/lib/node_modules/astx/node_modules/recast/lib/printer.js:55:31)
    at /path/to/astx/lib/node_modules/astx/node_modules/recast/lib/printer.js:49:41
    at FastPath.call (/path/to/astx/lib/node_modules/astx/node_modules/recast/lib/fast-path.js:125:18)
    at genericPrintNoParens (/path/to/astx/lib/node_modules/astx/node_modules/recast/lib/printer.js:200:29)
    at genericPrint (/path/to/astx/lib/node_modules/astx/node_modules/recast/lib/printer.js:123:30)
0 files changed
0 files unchanged
1 file errored```
@cowboy
Copy link
Author

cowboy commented Oct 5, 2021

I also get the Cannot read property 'raw' of undefined error with this file, so maybe it's a general problem with RegExp parsing:

module.exports = () => {
  const re = /foo/
}

@jedwards1211
Copy link
Contributor

🎉 This issue has been resolved in version 2.0.0-beta.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jedwards1211
Copy link
Contributor

Sorry about that!

@jedwards1211
Copy link
Contributor

🎉 This issue has been resolved in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

2 participants