read-package-json
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "read-package-json", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)", | ||
@@ -5,0 +5,0 @@ "description": "The thing npm uses to read package.json files with semantics and defaults and validation", |
@@ -70,3 +70,2 @@ // vim: set softtabstop=16 shiftwidth=16: | ||
cb = (function (orig) { return function (er, data) { | ||
if (er) readJson.log.error("readJson", file, er) | ||
if (data) readJson.cache.set(file, data); | ||
@@ -73,0 +72,0 @@ return orig(er, data) |
@@ -41,2 +41,33 @@ # read-package-json | ||
## readJson.log | ||
By default this is a reference to the `npmlog` module. But if that | ||
module can't be found, then it'll be set to just a dummy thing that does | ||
nothing. | ||
Replace with your own `{log,warn,error}` object for fun loggy time. | ||
## readJson.extras(file, data, cb) | ||
Run all the extra stuff relative to the file, with the parsed data. | ||
Modifies the data as it does stuff. Calls the cb when it's done. | ||
## readJson.extraSet = [fn, fn, ...] | ||
Array of functions that are called by `extras`. Each one receives the | ||
arguments `fn(file, data, cb)` and is expected to call `cb(er, data)` | ||
when done or when an error occurs. | ||
Order is indeterminate, so each function should be completely | ||
independent. | ||
Mix and match! | ||
## readJson.cache | ||
The `lru-cache` object that readJson uses to not read the same file over | ||
and over again. See | ||
[lru-cache](https://github.com/isaacs/node-lru-cache) for details. | ||
## Other Relevant Files Besides `package.json` | ||
@@ -111,3 +142,3 @@ | ||
## `{directories.man}/*.[0-9]` | ||
### `{directories.man}/*.[0-9]` | ||
@@ -123,3 +154,3 @@ If there is not already a `man` field defined as an array of files or a | ||
## `{directories.bin}/*` | ||
### `{directories.bin}/*` | ||
@@ -126,0 +157,0 @@ If there is not already a `bin` field defined as a string filename or a |
25672
163
490