-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: options.apis allows globs in addition to full file paths #19
Comments
Hi @jonboiser I like this idea. I'm using a glob function myself for generating this. var _ = require('lodash');
var glob = require('glob');
function(globPatterns, removeRoot) {
// For context switching
var _this = this;
// URL paths regex
var urlRegex = new RegExp('^(?:[a-z]+:)?\/\/', 'i');
// The output array
var output = [];
// If glob pattern is array so we use each pattern in a recursive way, otherwise we use glob
if (_.isArray(globPatterns)) {
globPatterns.forEach(function(globPattern) {
output = _.union(output, _this.getGlobbedFiles(globPattern, removeRoot));
});
} else if (_.isString(globPatterns)) {
if (urlRegex.test(globPatterns)) {
output.push(globPatterns);
} else {
var files = glob.sync(globPatterns);
if (removeRoot) {
files = files.map(function(file) {
return file.replace(removeRoot, '');
});
}
output = _.union(output, files);
}
}
return output;
}; |
Sounds good! I'll start working on it. |
Hi @jonboiser when will this feature be released as its something that's quite useful for the current project am working on. |
@monk8800 I've set up a PR implementing the feature. It's actually pretty simple; I just need to expand the test to cover it. I don't know when it would be released, but it's actually simple enough for you to bring in |
@monk8800: I plan on taking a look at it tomorrow. |
Sounds good |
This would be useful for projects that have lots routes/controllers broken up into many files. Also, when a new route module is introduced to the project, we will not need to add its path to the array.
Example:
If this would be a useful addition, I would be happy to submit a PR.
The text was updated successfully, but these errors were encountered: