capaj / require-globify

transform for browserify, which allows to require files with globbing expressions
MIT License
70 stars 11 forks source link

Support for a custom mode w/template string replacement #24

Open carlmathisen opened 8 years ago

carlmathisen commented 8 years ago

Hi capaj,

I wanted a simple reusable way of modifying the expand command by creating a custom mode. This way i can just pass a template parameter into require

files = [];
require('./**/*.js', {
  mode: 'custom',
  template: "files['{file}'] = require('{file}')"
})

outputs e.g:

files['./a.js'] = require('./a.js'); files['./b.js'] = require('./b.js');

Let me know if the principle is of interest.

call-a3 commented 8 years ago

Thanks, that seems like a very useful addition indeed! I'm very eager to merge this into develop, however I'd be even more indulgent if you could add some tests to back your new feature.

Could you add some examples of how you use this feature (example input and output) and if possible some edge cases in which this could go wrong? I can then put those in some testcases and add the feature :)

capaj commented 7 years ago

@carlmathisen thanks for opening this PR, but like @call-a3 we need those tests before we can merge.