joeybaker/remapify — pull request #9 by zachwolf (2014-08-06 03:28:56+00:00)
Title: adds filter option for filename tweaks

While working with browserify, I've found it useful to prefix files that I don't want being compiled with an underscore like `_avatar.js` or `_description.js` mentioned in your readme. However, I don't want to have to have the underscores in the require statements like `require('_avatar.js');`. I couldn't find a way to do this as of now, so I added an option with the task to tweak file names and add them to `expandedAliases`.

For example:

```js
b.plugin(remapify, [
{
src: './**/*.js'
, filter: function(fileName) { // fileName is passed as something like `./foo-dir/_bar-file.js`
return (/\/?((?:.(?!\/))+)$/) // regex for everything after the last '/' in the file name
.exec(fileName)[1] // get file name from `exec` method
.replace(/^\_/, '') // replace leading underscore
.replace(/\.js$/, ''); // replace file extension
}
}
]);
```

I played around with using the `remapify:file` event, but I felt like this was a cleaner way. What are your thoughts on this? Is there an easier way that I missed?