{"action":"created","issue":{"url":"https://api.github.com/repos/nightwatchjs/nightwatch/issues/960","repository_url":"https://api.github.com/repos/nightwatchjs/nightwatch","labels_url":"https://api.github.com/repos/nightwatchjs/nightwatch/issues/960/labels{/name}","comments_url":"https://api.github.com/repos/nightwatchjs/nightwatch/issues/960/comments","events_url":"https://api.github.com/repos/nightwatchjs/nightwatch/issues/960/events","html_url":"https://github.com/nightwatchjs/nightwatch/issues/960","id":151940183,"number":960,"title":"[Feature request] Overwrite custom commands","user":{"login":"aberonni","id":1260402,"avatar_url":"https://avatars.githubusercontent.com/u/1260402?v=3","gravatar_id":"","url":"https://api.github.com/users/aberonni","html_url":"https://github.com/aberonni","followers_url":"https://api.github.com/users/aberonni/followers","following_url":"https://api.github.com/users/aberonni/following{/other_user}","gists_url":"https://api.github.com/users/aberonni/gists{/gist_id}","starred_url":"https://api.github.com/users/aberonni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aberonni/subscriptions","organizations_url":"https://api.github.com/users/aberonni/orgs","repos_url":"https://api.github.com/users/aberonni/repos","events_url":"https://api.github.com/users/aberonni/events{/privacy}","received_events_url":"https://api.github.com/users/aberonni/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":17,"created_at":"2016-04-29T18:33:17Z","updated_at":"2016-08-03T20:35:35Z","closed_at":null,"body":"Given a folder structure similar to this:\n\n```\n├── custom_commands\n│   └── command1.js\n│   └── command2.js\n│   └── command3.js\n└── even_more_custom_commands\n       └── command2.js\n```\n\nI insert in my config.js this:\n\n```javascript\ncustom_commands_path: [\n    'custom_commands',\n    'even_more_custom_commands'\n]\n```\n\nI currently receive the error `The command \"command2\" is already defined!`.\n\nI would like to able to overwrite the command in the first folder with the command in the second folder. I guess ideally this could be a configurable option in the config.js file.\n\nI've already seen where this option could be handled in the addCommand function, if this feature request is aplroved I would be happy to submit a Pull Request."},"comment":{"url":"https://api.github.com/repos/nightwatchjs/nightwatch/issues/comments/237364495","html_url":"https://github.com/nightwatchjs/nightwatch/issues/960#issuecomment-237364495","issue_url":"https://api.github.com/repos/nightwatchjs/nightwatch/issues/960","id":237364495,"user":{"login":"senocular","id":3536716,"avatar_url":"https://avatars.githubusercontent.com/u/3536716?v=3","gravatar_id":"","url":"https://api.github.com/users/senocular","html_url":"https://github.com/senocular","followers_url":"https://api.github.com/users/senocular/followers","following_url":"https://api.github.com/users/senocular/following{/other_user}","gists_url":"https://api.github.com/users/senocular/gists{/gist_id}","starred_url":"https://api.github.com/users/senocular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/senocular/subscriptions","organizations_url":"https://api.github.com/users/senocular/orgs","repos_url":"https://api.github.com/users/senocular/repos","events_url":"https://api.github.com/users/senocular/events{/privacy}","received_events_url":"https://api.github.com/users/senocular/received_events","type":"User","site_admin":false},"created_at":"2016-08-03T20:35:35Z","updated_at":"2016-08-03T20:35:35Z","body":"@beatfactor Incidentally, there is no protection for this with page objects and page object commands, as seen with: \r\n\r\nhttps://groups.google.com/forum/#!topic/nightwatchjs/9KcQ9DVp_D4/discussion\r\n\r\nRelevant command handling code:\r\n\r\nhttps://github.com/nightwatchjs/nightwatch/blob/master/lib/page-object/page-utils.js#L80\r\n\r\nThough pages _do_ have a kind of fallback for this in that you can instead use `page.api`, though you'll lose element support (and of course command chaining context has changed).  I don't know if this was intended or an oversight ... ?\r\n\r\nThe namespace issue can be a complicated one.  You not only have api, but extensions of that (in a way) with pages and sections.  They also get access to custom commands but have a different interface for potential collisions (`parent`, `getUrl`, etc.).  Combine that with page object commands (which are more like methods, since they're not added to the command queue like other custom commands), and how they stomp on whatever haphazardly and it gets a little more messy. Then you have something like #884 - one I've attempted to come up with a solution for but it didn't quite work out as nicely as I'd hoped.\r\n\r\nThat being said, as far as limiting custom commands overwrites, this can probably be achieved with a buffer target during command loading.  Run through all of the custom command modules, adding those commands to the buffer, allowing overwrites, then copy from that buffer into the api, and only then, throwing on duplicates.  It sounds simple enough in my head (don't they all?); maybe I'll try to shoot out a PR for it tonight."}}
{"actor":{"display_login":"senocular"}}