MCPcopy Create free account
hub / github.com/node-config/node-config / locateMatchingFiles

Method locateMatchingFiles

lib/util.js:381–403  ·  view source on GitHub ↗

* Return a list of fullFilenames who exists in allowedFiles * Ordered according to allowedFiles argument specifications * * @method locateMatchingFiles * @param {string} configDirs the config dir, or multiple dirs separated by a column (:) * @param {Object} allowedFiles an object. k

(configDirs, allowedFiles)

Source from the content-addressed store, hash-verified

379 * @returns {string[]} fullFilenames - path + filename
380 */
381 static locateMatchingFiles(configDirs, allowedFiles) {
382 return configDirs.split(Path.delimiter)
383 .filter(Boolean)
384 .reduce(function (files, configDir) {
385 configDir = _toAbsolutePath(configDir);
386 try {
387 FileSystem.readdirSync(configDir)
388 .filter(file => allowedFiles[file])
389 .forEach(function (file) {
390 files.push([allowedFiles[file], Path.join(configDir, file)]);
391 });
392 } catch (e) {
393 }
394
395 return files;
396 }, [])
397 .sort(function (a, b) {
398 return a[0] - b[0];
399 })
400 .map(function (file) {
401 return file[1];
402 });
403 }
404
405 /**
406 *

Callers 4

loadFileConfigsMethod · 0.95
loadCustomEnvVarsMethod · 0.80
0-util.jsFile · 0.80
util.tsFile · 0.80

Calls 1

_toAbsolutePathFunction · 0.85

Tested by

no test coverage detected