wesleytodd / YeoPress

A Yeoman generator for WordPress
Other
1.08k stars 163 forks source link

Resolve the issue "has no method split()" #115

Closed cezarsmpio closed 9 years ago

cezarsmpio commented 9 years ago

Added the toString method, because the input parameter was returning a object.

wesleytodd commented 9 years ago

Was it an Array or an Object? If it was an array then just wrapping the split in an instance of check would work. My guess is that it is converted to an array somewhere before this, so it is already in the form you need without the split entirely.

cezarsmpio commented 9 years ago

I think the version of node or npm has changed the return of parameter to Object, it was returning plugin-a, plugin-b, plugin-c as object. I typed just console.log(typeof input) and if the parameter is Object or Array the toString() method will work in this case and the parameter input needs obligatorily a String, check the doc of split: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split

Thanks.

wesleytodd commented 9 years ago

Calling toString() on a basic object will return '[Object object]', while calling it on an array will return the items separated by commas. I double checked in the console, so this must be an array. In which case just deleting the line should do just as well as this, or wrapping it in the check like I said above. If you cannot get to this today I can probably do it tonight.

cezarsmpio commented 9 years ago

In all tests, the return was [object Array], I used console.log(Object.prototype.toString.call(plugins));, I don't quite understand the real problem, but using just toString() solved my problem, in all tests.

I think you will improve better than me.

Thanks!

cezarsmpio commented 9 years ago

Any progress? Thanks!

wesleytodd commented 9 years ago

Maybe it is something do with recent updates, but on the develop branch I am not getting this issue. If you get the chance to test it out and it is still there we can re-open this. Let me know!