{"action":"closed","issue":{"url":"https://api.github.com/repos/yeoman/yeoman/issues/1461","labels_url":"https://api.github.com/repos/yeoman/yeoman/issues/1461/labels{/name}","comments_url":"https://api.github.com/repos/yeoman/yeoman/issues/1461/comments","events_url":"https://api.github.com/repos/yeoman/yeoman/issues/1461/events","html_url":"https://github.com/yeoman/yeoman/issues/1461","id":53476592,"number":1461,"title":"Namespace resolving incorrectly from Environment.prototype.namespace","user":{"login":"adenhertog","id":6031613,"avatar_url":"https://avatars.githubusercontent.com/u/6031613?v=3","gravatar_id":"","url":"https://api.github.com/users/adenhertog","html_url":"https://github.com/adenhertog","followers_url":"https://api.github.com/users/adenhertog/followers","following_url":"https://api.github.com/users/adenhertog/following{/other_user}","gists_url":"https://api.github.com/users/adenhertog/gists{/gist_id}","starred_url":"https://api.github.com/users/adenhertog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adenhertog/subscriptions","organizations_url":"https://api.github.com/users/adenhertog/orgs","repos_url":"https://api.github.com/users/adenhertog/repos","events_url":"https://api.github.com/users/adenhertog/events{/privacy}","received_events_url":"https://api.github.com/users/adenhertog/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-06T03:18:15Z","updated_at":"2015-01-06T19:16:12Z","closed_at":"2015-01-06T19:16:12Z","body":"Hi,\r\n\r\nI've been working with yeoman-environment over the past couple of days as I'm wanting it scaffold out various bits from a Nodejs back end. Yeoman's been great so far.\r\n\r\nHowever I'm having an issue when it's trying to resolve a namespace from a path. \r\n\r\nThe following path will resolve the namespace incorrectly (in environment.js:Environment.prototype.namespace)\r\n\r\n```\r\nc:\\projects\\yeoman\\generators\\generator-example\\generators\\app\\index.js \r\nEXPECTED: example:app\r\nACTUAL: example:generators:app\r\n```\r\n\r\nLookups:\r\n```javascript\r\n['.', 'generators', 'lib/generators']\r\n```\r\n\r\nThis happens because the first \"generators\" in the path is being replaced. I believe this should replace the last matched lookup in the reduce function like:\r\n\r\n```javascript\r\n  // if `ns` contain a lookup dir in it's path, remove it.\r\n  ns = lookups.reduce(function (ns, lookup) {\r\n\t// ensure that the lookup is removed from the lowest level folder, and that partial folder names aren't removed\r\n  \tvar folders = ns.split(path.sep);\r\n  \tvar replaceIndex = folders.lastIndexOf(lookup);\r\n  \tif (replaceIndex > -1) {\r\n  \t\tfolders.splice(replaceIndex, 1);\r\n  \t}\r\n  \tvar resolvedPath = folders.join(path.sep);\r\n  \treturn resolvedPath;\r\n  }, ns);\r\n```\r\n\r\nThis will also avoid it doing replaces like:\r\n...\\generator-example\\generators-foo\\app\\index.js\r\n...\\generator-example\\-foo\\app\\index.js"}}