Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

look-up

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

look-up - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

LICENSE

69

index.js

@@ -10,3 +10,4 @@ 'use strict';

var isGlob = require('is-glob');
var mm = require('multimatch');
var mm = require('micromatch');
var dir = process.cwd();

@@ -27,28 +28,31 @@ /**

options = options || {matchBase: true};
var cwd = options.cwd || process.cwd();
var plen = patterns.length;
var opts = options || {};
var cwd = opts.cwd || process.cwd();
var len = patterns.length;
// loop over patterns
while (plen--) {
var pattern = patterns[plen];
while (len--) {
var pattern = patterns[len];
// if the pattern is a glob pattern, move on
if (isGlob(pattern)) {
continue;
if (!isGlob(pattern)) {
// if the pattern is not a glob pattern, try
// to see if it resolves to an actual file so
// we can avoid using fs.readdir and matching
var file = path.join(cwd, pattern);
if (fs.existsSync(file)) {
return file;
}
} else if (!/\*\*/.test(pattern)) {
opts.matchBase = true;
}
// if the pattern is not a glob pattern, try
// to see if it resolves to an actual file so
// we can avoid using minimatch
var tmp = path.join(cwd, pattern);
if (fs.existsSync(tmp)) {
return tmp;
}
}
var files = fs.readdirSync(cwd);
var len = files.length;
var flen = files.length;
// loop through the files in the current directory
while (len--) {
var fp = path.join(cwd, files[len]);
while (flen--) {
var fp = path.join(cwd, files[flen]);

@@ -58,22 +62,19 @@ // if the current directory is the actual cwd, break out

// check the file path to see if it matches the pattern(s)
var match = mm(fp, patterns, options);
if (match.length === 0) {
continue;
// if the file path matches the pattern(s), return it
var match = mm(fp, patterns, opts);
if (match.length !== 0) {
return fp;
}
return fp;
}
// since nothing was matched in the last dir,
// move up a directory and create a new `cwd` for the search
cwd = path.join(cwd, '..');
if (cwd !== '..') {
// since we haven't run out of dirs yet, try again
options.cwd = cwd;
return lookup(patterns, options);
}
// nothing was matched in the last dir, so move up a
// directory and create a new `cwd` for the search
cwd = path.resolve(cwd, '..');
// if we're here, it means we're past the actual cwd
// so we've gone too far, no matches...
return null;
// we're past the actual cwd with no matches.
if (cwd === dir) return null;
// try again
opts.cwd = cwd;
return lookup(patterns, opts);
};
{
"name": "look-up",
"description": "Like findup-sync and supports the same features but 20x-40x faster on avg.",
"version": "0.4.1",
"version": "0.5.0",
"homepage": "https://github.com/jonschlinkert/look-up",

@@ -29,13 +29,13 @@ "author": {

"dependencies": {
"is-glob": "^0.1.0",
"multimatch": "^1.0.1"
"is-glob": "^1.1.0",
"micromatch": "^1.0.1"
},
"devDependencies": {
"benchmarked": "^0.1.2",
"benchmarked": "^0.1.3",
"chalk": "^0.5.1",
"findup-sync": "^0.1.3",
"findup-sync": "^0.2.1",
"mocha": "*",
"normalize-path": "^0.3.0",
"resolve": "^1.0.0",
"should": "^4.1.0"
"should": "*"
},

@@ -42,0 +42,0 @@ "keywords": [

@@ -69,3 +69,3 @@ # look-up [![NPM version](https://badge.fury.io/js/look-up.svg)](http://badge.fury.io/js/look-up)

## License
Copyright (c) 2014 Jon Schlinkert
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license

@@ -75,5 +75,5 @@

_This file was generated by [verb](https://github.com/assemble/verb) on December 18, 2014._
_This file was generated by [verb](https://github.com/assemble/verb) on January 19, 2015._
[minimatch]: http://github.com/isaacs/minimatch
[findup-sync]: https://github.com/cowboy/node-findup-sync
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc