{"action":"created","issue":{"url":"https://api.github.com/repos/aseemk/requireDir/issues/26","labels_url":"https://api.github.com/repos/aseemk/requireDir/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/aseemk/requireDir/issues/26/comments","events_url":"https://api.github.com/repos/aseemk/requireDir/issues/26/events","html_url":"https://github.com/aseemk/requireDir/pull/26","id":121768046,"number":26,"title":"Added new options \"append\", \"prepend\", \"cleanup\" and \"transform\"","user":{"login":"manuelbieh","id":239546,"avatar_url":"https://avatars.githubusercontent.com/u/239546?v=3","gravatar_id":"","url":"https://api.github.com/users/manuelbieh","html_url":"https://github.com/manuelbieh","followers_url":"https://api.github.com/users/manuelbieh/followers","following_url":"https://api.github.com/users/manuelbieh/following{/other_user}","gists_url":"https://api.github.com/users/manuelbieh/gists{/gist_id}","starred_url":"https://api.github.com/users/manuelbieh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manuelbieh/subscriptions","organizations_url":"https://api.github.com/users/manuelbieh/orgs","repos_url":"https://api.github.com/users/manuelbieh/repos","events_url":"https://api.github.com/users/manuelbieh/events{/privacy}","received_events_url":"https://api.github.com/users/manuelbieh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-12-11T18:46:36Z","updated_at":"2016-01-20T13:39:12Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/aseemk/requireDir/pulls/26","html_url":"https://github.com/aseemk/requireDir/pull/26","diff_url":"https://github.com/aseemk/requireDir/pull/26.diff","patch_url":"https://github.com/aseemk/requireDir/pull/26.patch"},"body":"Hey,\r\n\r\nI needed a way to differ between modules from different folders (in my case *controllers* and *models*) which made me add an `append` option:\r\n\r\n```\r\nvar requireDir = require('require-dir');\r\nvar _ = require('lodash');\r\n\r\nvar models = requireDir('./models', {append: 'Model', cleanup: true});\r\nvar controllers = requireDir('./controllers', {append: 'Controller', cleanup: true});\r\n\r\nconsole.log(_.merge(models, controllers));\r\n```\r\n\r\n=> `{ aModel: 'a', bModel: 'b', aController: 'a', bController: 'b' }`\r\n\r\nI also added a new option `transform` since I wanted my modules to be compliant with my UpperCamelCase convention, so I added `transform: 'ucfirst'` as new option which will return `Login` if the file is named 'login.js'\r\n\r\nAnd because it's nothing else than another transformation-style I also allowed `camelcase` to be used as value for the transform option: `{ transform: ['camelcase', 'ucfirst'] }` (or simply `{ transform: 'camelcase ucfirst' }` since it is a simple indexOf lookup). I did not remove the old `camelcase` option to be backwards compatible.\r\n\r\nTo avoid having confusing module names with the same name in the returned object, I also added another option `cleanup` which removes modules which were renamed using a `transform`, `append` or `prepend`.\r\n\r\nI added tests for every new option to make sure nothing breaks. All new options are of course optional and everything should be completely backwards compatible so it can be merged safely :)"},"comment":{"url":"https://api.github.com/repos/aseemk/requireDir/issues/comments/173207017","html_url":"https://github.com/aseemk/requireDir/pull/26#issuecomment-173207017","issue_url":"https://api.github.com/repos/aseemk/requireDir/issues/26","id":173207017,"user":{"login":"manuelbieh","id":239546,"avatar_url":"https://avatars.githubusercontent.com/u/239546?v=3","gravatar_id":"","url":"https://api.github.com/users/manuelbieh","html_url":"https://github.com/manuelbieh","followers_url":"https://api.github.com/users/manuelbieh/followers","following_url":"https://api.github.com/users/manuelbieh/following{/other_user}","gists_url":"https://api.github.com/users/manuelbieh/gists{/gist_id}","starred_url":"https://api.github.com/users/manuelbieh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manuelbieh/subscriptions","organizations_url":"https://api.github.com/users/manuelbieh/orgs","repos_url":"https://api.github.com/users/manuelbieh/repos","events_url":"https://api.github.com/users/manuelbieh/events{/privacy}","received_events_url":"https://api.github.com/users/manuelbieh/received_events","type":"User","site_admin":false},"created_at":"2016-01-20T13:39:12Z","updated_at":"2016-01-20T13:39:12Z","body":"By the way: my PR is fully backwards compatible. Breaks nothing, adds new features, covered with tests. So it would most certainly not cause any problems to merge my PR ;)"}}