(list)
| 295 | // expand(['file*.js']) = ['file1.js', 'file2.js', ...] |
| 296 | // (if the files 'file1.js', 'file2.js', etc, exist in the current dir) |
| 297 | function expand(list) { |
| 298 | if (!Array.isArray(list)) { |
| 299 | throw new TypeError('must be an array'); |
| 300 | } |
| 301 | var expanded = []; |
| 302 | list.forEach(function (listEl) { |
| 303 | // Don't expand non-strings |
| 304 | if (typeof listEl !== 'string') { |
| 305 | expanded.push(listEl); |
| 306 | } else { |
| 307 | var ret; |
| 308 | var globOpts = globOptions(); |
| 309 | try { |
| 310 | ret = glob.sync(listEl, globOpts); |
| 311 | } catch (e) { |
| 312 | // if glob fails, interpret the string literally |
| 313 | ret = [listEl]; |
| 314 | } |
| 315 | // if nothing matched, interpret the string literally |
| 316 | ret = ret.length > 0 ? ret.sort() : [listEl]; |
| 317 | if (globOpts.nodir) { |
| 318 | ret = ret.filter(function (file) { |
| 319 | return !statNoFollowLinks(file).isDirectory(); |
| 320 | }); |
| 321 | } |
| 322 | expanded = expanded.concat(ret); |
| 323 | } |
| 324 | }); |
| 325 | return expanded; |
| 326 | } |
| 327 | exports.expand = expand; |
| 328 | |
| 329 | // Normalizes Buffer creation, using Buffer.alloc if possible. |
no test coverage detected
searching dependent graphs…