Socket
Socket
Sign inDemoInstall

findup-sync

Package Overview
Dependencies
49
Maintainers
4
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.2 to 0.4.3

README.md

54

index.js

@@ -22,4 +22,7 @@ 'use strict';

module.exports = function(patterns, options) {
options = options || {};
var cwd = path.resolve(resolveDir(options.cwd || ''));
if (typeof patterns === 'string') {
return lookup(patterns, options);
return lookup(cwd, [patterns], options);
}

@@ -31,7 +34,16 @@

return lookup(cwd, patterns, options);
};
function lookup(cwd, patterns, options) {
var len = patterns.length;
var idx = -1;
var res;
while (++idx < len) {
var res = lookup(patterns[idx], options);
if (isGlob(patterns[idx])) {
res = matchFile(cwd, patterns[idx], options);
} else {
res = findFile(cwd, patterns[idx], options);
}
if (res) {

@@ -42,13 +54,7 @@ return res;

return null;
};
function lookup(pattern, options) {
options = options || {};
var cwd = path.resolve(resolveDir(options.cwd || ''));
if (isGlob(pattern)) {
return matchFile(cwd, pattern, options);
} else {
return findFile(cwd, pattern, options);
var dir = path.dirname(cwd);
if (dir === cwd) {
return null;
}
return lookup(dir, patterns, options);
}

@@ -69,28 +75,8 @@

}
var dir = path.dirname(cwd);
if (dir === cwd) {
return null;
}
return matchFile(dir, pattern, opts);
return null;
}
function findFile(cwd, filename, options) {
var res;
var fp = cwd ? path.resolve(cwd, filename) : filename;
if (res = detect(fp, options)) {
return res;
}
var segs = cwd.split(path.sep);
var len = segs.length;
while (len--) {
cwd = segs.slice(0, len).join(path.sep);
fp = path.resolve(cwd, filename);
if (res = detect(fp, options)) {
return res;
}
}
return null;
return detect(fp, options);
}

@@ -97,0 +83,0 @@

{
"name": "findup-sync",
"description": "Find the first file matching a given pattern in the current directory or the nearest ancestor directory.",
"version": "0.4.2",
"version": "0.4.3",
"homepage": "https://github.com/cowboy/node-findup-sync",

@@ -6,0 +6,0 @@ "author": "\"Cowboy\" Ben Alman (http://benalman.com)",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc