Skip to content

Commit 2753f8e

Browse files
author
Jonathan Boiser
committed
Factor out glob converter function.
1 parent e73de29 commit 2753f8e

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

lib/index.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,20 @@ function addDataToSwaggerObject(swaggerObject, data) {
126126
}
127127
}
128128

129+
/**
130+
* Converts an array of globs to full paths
131+
* @function
132+
* @param {array} globs - Array of globs and/or normal paths
133+
* @return {array} Array of fully-qualified paths
134+
* @requires glob
135+
*/
136+
function convertGlobPaths(globs) {
137+
return globs.reduce(function(acc, globString) {
138+
var globFiles = glob.sync(globString);
139+
return acc.concat(globFiles);
140+
}, []);
141+
}
142+
129143
/**
130144
* Generates the swagger spec
131145
* @function
@@ -153,11 +167,7 @@ module.exports = function(options) {
153167
swaggerObject.parameters = {};
154168
swaggerObject.securityDefinitions = {};
155169

156-
// Build up the array of file names
157-
var apiPaths = options.apis.reduce(function(acc, file) {
158-
var globFiles = glob.sync(file);
159-
return acc.concat(globFiles);
160-
}, []);
170+
var apiPaths = convertGlobPaths(options.apis);
161171

162172
// Parse the documentation in the APIs array.
163173
for (var i = 0; i < apiPaths.length; i = i + 1) {

0 commit comments

Comments
 (0)