dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

Adding any function to Array prototype borks Vorpal #175

Open devinus opened 8 years ago

devinus commented 8 years ago

Many packages (unfortunately) do this:

Array.prototype.pewp = function() {
  return 'pewp';
}

Which results in:

rebelmail-templates$ upload-images 

  Invalid option: 'function () {
  return 'pewp';
}'. Showing Help: function () {
  return 'pewp';
}

  Usage: upload-images [options] [template]

  Upload images to S3.

  Options:

    --help                 output usage information
    -b, --bucket <bucket>  S3 bucket
    -a, --acl <acl>        S3 ACL
 function () {
  return 'pewp';
}
devinus commented 8 years ago

https://github.com/dthree/vorpal/blob/ff19d3600f47a6a568b6e5477c8c738523a39b54/lib/util.js#L311

If we use hasOwnProperty everywhere I don't think this problem will exist.

devinus commented 8 years ago

Pinging @scotthovestadt as I believe https://github.com/dthree/vorpal/commit/a337dce615f3420e398a9f7ea3603bc31c8d0c32 is what changed behavior to surface this. (Vorpal 1.10 did not exhibit it.)