Unexpected error
cowboy opened this issue ยท 4 comments
cowboy commented
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 commented
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 commented
๐ This issue has been resolved in version 2.0.0-beta.6 ๐
The release is available on:
Your semantic-release bot ๐ฆ๐
jedwards1211 commented
Sorry about that!
jedwards1211 commented
๐ This issue has been resolved in version 2.0.0 ๐
The release is available on:
Your semantic-release bot ๐ฆ๐