findup-sync
Advanced tools
Comparing version 0.4.0 to 0.4.1
28
index.js
@@ -11,2 +11,3 @@ 'use strict'; | ||
var resolveDir = require('resolve-dir'); | ||
var exists = require('fs-exists-sync'); | ||
var mm = require('micromatch'); | ||
@@ -30,5 +31,7 @@ | ||
var len = patterns.length, i = -1; | ||
while (++i < len) { | ||
var res = lookup(patterns[i], options); | ||
var len = patterns.length; | ||
var idx = -1; | ||
while (++idx < len) { | ||
var res = lookup(patterns[idx], options); | ||
if (res) { | ||
@@ -44,3 +47,3 @@ return res; | ||
options = options || {}; | ||
var cwd = resolveDir(options.cwd || ''); | ||
var cwd = path.resolve(resolveDir(options.cwd || '')); | ||
if (isGlob(pattern)) { | ||
@@ -56,6 +59,7 @@ return matchFile(cwd, pattern, options); | ||
var files = fs.readdirSync(cwd); | ||
var len = files.length, i = -1; | ||
var len = files.length; | ||
var idx = -1; | ||
while (++i < len) { | ||
var name = files[i]; | ||
while (++idx < len) { | ||
var name = files[idx]; | ||
var fp = path.join(cwd, name); | ||
@@ -75,4 +79,4 @@ if (isMatch(name) || isMatch(fp)) { | ||
function findFile(cwd, filename) { | ||
var fp = cwd ? (cwd + '/' + filename) : filename; | ||
if (fs.existsSync(fp)) { | ||
var fp = cwd ? path.resolve(cwd, filename) : filename; | ||
if (exists(fp)) { | ||
return fp; | ||
@@ -85,5 +89,5 @@ } | ||
while (len--) { | ||
cwd = segs.slice(0, len).join('/'); | ||
fp = cwd + '/' + filename; | ||
if (fs.existsSync(fp)) { | ||
cwd = segs.slice(0, len).join(path.sep); | ||
fp = path.resolve(cwd, filename); | ||
if (exists(fp)) { | ||
return fp; | ||
@@ -90,0 +94,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.0", | ||
"version": "0.4.1", | ||
"homepage": "https://github.com/cowboy/node-findup-sync", | ||
@@ -23,2 +23,3 @@ "author": "\"Cowboy\" Ben Alman (http://benalman.com)", | ||
"dependencies": { | ||
"fs-exists-sync": "^0.1.0", | ||
"is-glob": "^2.0.1", | ||
@@ -29,3 +30,3 @@ "micromatch": "^2.3.7", | ||
"devDependencies": { | ||
"grunt": "^0.4.5", | ||
"grunt": "^1.0.1", | ||
"grunt-contrib-jshint": "^0.12.0", | ||
@@ -36,4 +37,4 @@ "is-absolute": "^0.2.3", | ||
"normalize-path": "^2.0.1", | ||
"resolve": "^1.1.7", | ||
"user-home": "^2.0.0" | ||
"os-homedir": "^1.0.1", | ||
"resolve": "^1.1.7" | ||
}, | ||
@@ -40,0 +41,0 @@ "keywords": [ |
@@ -1,2 +0,2 @@ | ||
# findup-sync [![Build Status](https://travis-ci.org/cowboy/node-findup-sync.svg)](https://travis-ci.org/cowboy/node-findup-sync) [![NPM version](https://badge.fury.io/js/findup-sync.svg)](http://badge.fury.io/js/findup-sync) | ||
# findup-sync [![Build Status](https://travis-ci.org/js-cli/node-findup-sync.svg)](https://travis-ci.org/js-cli/node-findup-sync) [![NPM version](https://badge.fury.io/js/findup-sync.svg)](http://badge.fury.io/js/findup-sync) | ||
@@ -3,0 +3,0 @@ > Find the first file matching a given pattern in the current directory or the nearest ancestor directory. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5546
76
4
3
1
+ Addedfs-exists-sync@^0.1.0
+ Addedfs-exists-sync@0.1.0(transitive)