diff options
author | 2020-11-18 23:26:45 +0100 | |
---|---|---|
committer | 2020-11-18 23:26:45 +0100 | |
commit | 81ddf9b700bc48a1f8e472209f080f9c1d9a9b09 (patch) | |
tree | 8b959d50c5a614cbf9fcb346ed556140374d4b6d /node_modules/findup-sync/index.js | |
parent | 1870f3fdf43707a15fda0f609a021f516f45eb63 (diff) | |
download | website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.tar.gz website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.tar.bz2 website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.zip |
rm node_modules
Diffstat (limited to 'node_modules/findup-sync/index.js')
-rw-r--r-- | node_modules/findup-sync/index.js | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/node_modules/findup-sync/index.js b/node_modules/findup-sync/index.js deleted file mode 100644 index 2a9e117..0000000 --- a/node_modules/findup-sync/index.js +++ /dev/null @@ -1,87 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -var fs = require('fs'); -var path = require('path'); -var isGlob = require('is-glob'); -var resolveDir = require('resolve-dir'); -var detect = require('detect-file'); -var mm = require('micromatch'); - -/** - * @param {String|Array} `pattern` Glob pattern or file path(s) to match against. - * @param {Object} `options` Options to pass to [micromatch]. Note that if you want to start in a different directory than the current working directory, specify the `options.cwd` property here. - * @return {String} Returns the first matching file. - * @api public - */ - -module.exports = function(patterns, options) { - options = options || {}; - var cwd = path.resolve(resolveDir(options.cwd || '')); - - if (typeof patterns === 'string') { - return lookup(cwd, [patterns], options); - } - - if (!Array.isArray(patterns)) { - throw new TypeError('findup-sync expects a string or array as the first argument.'); - } - - return lookup(cwd, patterns, options); -}; - -function lookup(cwd, patterns, options) { - var len = patterns.length; - var idx = -1; - var res; - - while (++idx < len) { - if (isGlob(patterns[idx])) { - res = matchFile(cwd, patterns[idx], options); - } else { - res = findFile(cwd, patterns[idx], options); - } - if (res) { - return res; - } - } - - var dir = path.dirname(cwd); - if (dir === cwd) { - return null; - } - return lookup(dir, patterns, options); -} - -function matchFile(cwd, pattern, opts) { - var isMatch = mm.matcher(pattern, opts); - var files = tryReaddirSync(cwd); - var len = files.length; - var idx = -1; - - while (++idx < len) { - var name = files[idx]; - var fp = path.join(cwd, name); - if (isMatch(name) || isMatch(fp)) { - return fp; - } - } - return null; -} - -function findFile(cwd, filename, options) { - var fp = cwd ? path.resolve(cwd, filename) : filename; - return detect(fp, options); -} - -function tryReaddirSync(fp) { - try { - return fs.readdirSync(fp); - } catch (err) { - // Ignore error - } - return []; -} |