[Pkg-javascript-commits] [node-module-deps] 83/444: opts.cache, docs, 0.9.0

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:47:45 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-module-deps.

commit 05d14c181b1d35d94cf1d8cc4654e9aac991c494
Author: James Halliday <mail at substack.net>
Date:   Wed May 29 18:56:59 2013 -0700

    opts.cache, docs, 0.9.0
---
 index.js        | 7 +++++--
 package.json    | 2 +-
 readme.markdown | 3 +++
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/index.js b/index.js
index 0acbb1d..460c585 100644
--- a/index.js
+++ b/index.js
@@ -10,6 +10,7 @@ var concatStream = require('concat-stream');
 
 module.exports = function (mains, opts) {
     if (!opts) opts = {};
+    var cache = opts.cache;
     
     if (!Array.isArray(mains)) mains = [ mains ].filter(Boolean);
     mains = mains.map(function (file) {
@@ -18,7 +19,6 @@ module.exports = function (mains, opts) {
     
     var visited = {};
     var pending = 0;
-    var cache = {};
     
     var output = through();
     
@@ -66,7 +66,10 @@ module.exports = function (mains, opts) {
             }
             visited[file] = true;
             
-            fs.readFile(file, 'utf8', function (err, src) {
+            if (cache && cache[file]) {
+                applyTransforms(file, trx, cache[file]);
+            }
+            else fs.readFile(file, 'utf8', function (err, src) {
                 if (err) return output.emit('error', err);
                 applyTransforms(file, trx, src);
             });
diff --git a/package.json b/package.json
index 9fe3be5..ca6feb8 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "module-deps",
-    "version": "0.8.0",
+    "version": "0.9.0",
     "description": "walk the dependency graph to generate json output that can be fed into browser-pack",
     "main": "index.js",
     "bin": {
diff --git a/readme.markdown b/readme.markdown
index dc78ac9..765f144 100644
--- a/readme.markdown
+++ b/readme.markdown
@@ -81,6 +81,9 @@ the values. `opts.packageFilter(pkg)` should return the new `pkg` object to use.
 * opts.noParse - an array of absolute paths to not parse for dependencies. Use
 this for large dependencies like jquery or threejs which take forever to parse.
 
+* opts.cache - an object mapping filenames to strings of file contents to skip
+doing fs.readFile() calls
+
 # transforms
 
 module-deps can be configured to run source transformations on files before

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-module-deps.git



More information about the Pkg-javascript-commits mailing list