TypeError: Cannot read property 'type' of undefined at Groundskeeper.removeNamespace
mseeley opened this issue · comments
Working against Groundskeeper 0.1.5 I'm running into a TypeError while Groundskeeper attempts namespace removal.
lgmac-mseeley1:working mseeley$ groundskeeper -n util.log.debug < test.js
/usr/local/lib/node_modules/groundskeeper/lib/groundskeeper.js:183
while ([type.CallExpression, type.AssignmentExpression].indexOf(node.type) ===
^
TypeError: Cannot read property 'type' of undefined
at Groundskeeper.removeNamespace (/usr/local/lib/node_modules/groundskeeper/lib/groundskeeper.js:183:77)
at Groundskeeper.clean (/usr/local/lib/node_modules/groundskeeper/lib/groundskeeper.js:116:18)
at walk (/usr/local/lib/node_modules/groundskeeper/node_modules/falafel/index.js:60:9)
at module.exports (/usr/local/lib/node_modules/groundskeeper/node_modules/falafel/index.js:57:17)
at Array.forEach (native)
at forEach (/usr/local/lib/node_modules/groundskeeper/node_modules/falafel/index.js:8:31)
at walk (/usr/local/lib/node_modules/groundskeeper/node_modules/falafel/index.js:44:9)
at module.exports (/usr/local/lib/node_modules/groundskeeper/node_modules/falafel/index.js:51:25)
at Array.forEach (native)
at forEach (/usr/local/lib/node_modules/groundskeeper/node_modules/falafel/index.js:8:31)
Where test.js contains:
var dbg = util.log.debug;
dbg('foo');
I've included a replacement character as well via -r '0' which yielded the same result.
Node version: 0.8.14
groundskeeper@0.1.5
I took a look at this bug, and unfortunately when I fix it, hell breaks loose on my other tests, this might take a while, and I can't afford to look at this problem before sunday. =\
However, even if I fix the bug, the generated code will be invalid since the dbg
variable will hold the value '0' and next you'll call it as if it was a function, but it's a string. I've added an issue to this here since it's a totally different problem.
Hi Couto, thanks for taking a look when you have time. Adding the "-r 0" in my tests was just an attempt to trigger a possible different code path.
In the test.js case leaving either var dbg;
or stripping the empty var
altogether would be suitable. There are probably cases this approach doesn't cover.
I'm looking into a reduced code sample based off Groundskeeper.prototype.removeNamespace
.
:)