package-lookup
Advanced tools
Comparing version 0.1.0 to 0.1.1
13
index.js
@@ -9,3 +9,8 @@ var pkg = exports; | ||
function doCache(uncachedFiles, value) { | ||
function doCache(uncachedFiles, pkgFile, value) { | ||
if (pkgFile && value) { | ||
value._filename = pkgFile; | ||
value._dirname = path.dirname(pkgFile); | ||
} | ||
uncachedFiles.forEach(function(filename) { | ||
@@ -32,3 +37,3 @@ cache[filename] = value; | ||
if (pkgFile in cache) { | ||
return doCache(uncached, cache[pkgFile]); | ||
return doCache(uncached, pkgFile, cache[pkgFile]); | ||
} | ||
@@ -53,9 +58,9 @@ | ||
return doCache(uncached, pkgInfo || {}); | ||
return doCache(uncached, pkgFile, pkgInfo || {}); | ||
} | ||
var parentDir = path.dirname(dir); | ||
if (parentDir === dir) return doCache(uncached, null); | ||
if (parentDir === dir) return doCache(uncached, null, null); | ||
dir = parentDir; | ||
} | ||
}; |
{ | ||
"name" : "package-lookup", | ||
"description" : "Info about the package given a filename.", | ||
"version" : "0.1.0", | ||
"version" : "0.1.1", | ||
"author" : { | ||
@@ -6,0 +6,0 @@ "name" : "Bjarke Walling", |
@@ -24,1 +24,8 @@ package-lookup | ||
``` | ||
Functions: | ||
* pkg.resolve(filename) | ||
* pkg.resolveDir(dirname) | ||
The package info includes the properties `_filename` and `_dirname` that gives the filename and directory of the package.json file. |
2386
49
31