[Pkg-javascript-commits] [node-deps-sort] 29/79: remap dependency indexes

Bastien Roucariès rouca at moszumanska.debian.org
Wed Sep 6 09:41:54 UTC 2017


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

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

commit a01c84f49208cf4d496e6e8c8158e5428147a3db
Author: James Halliday <mail at substack.net>
Date:   Mon Jul 21 07:25:33 2014 -0700

    remap dependency indexes
---
 index.js             | 9 +++++++--
 test/dedupe_index.js | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/index.js b/index.js
index 6889ec4..55e8060 100644
--- a/index.js
+++ b/index.js
@@ -25,12 +25,13 @@ function sorter (rows, tr, opts) {
         }, {});
     }
     
-    var hashes = {};
+    var hashes = {}, deduped = {};
     if (opts.dedupe) {
         rows.forEach(function (row, ix) {
             var h = shasum(row.source);
             if (hashes[h]) {
                 row.dedupe = hashes[h];
+                deduped[row.id] = hashes[h];
             }
             else {
                 hashes[h] = row.id;
@@ -57,7 +58,11 @@ function sorter (rows, tr, opts) {
         rows.forEach(function (row) {
             row.indexDeps = {};
             Object.keys(row.deps).forEach(function (key) {
-                row.indexDeps[key] = index[row.deps[key]];
+                var id = row.deps[key];
+                if (has(deduped, id)) {
+                    id = deduped[id];
+                }
+                row.indexDeps[key] = index[id];
             });
             if (row.dedupe) {
                 row.dedupeIndex = index[row.dedupe];
diff --git a/test/dedupe_index.js b/test/dedupe_index.js
index fb6348a..8e87855 100644
--- a/test/dedupe_index.js
+++ b/test/dedupe_index.js
@@ -30,7 +30,7 @@ test('dedupe index', function (t) {
                 deps: { './foo': '/foo.js', './bar': '/bar.js' },
                 source: 'ONE',
                 index: 3,
-                indexDeps: { './foo': 2, './bar': 1 },
+                indexDeps: { './foo': 1, './bar': 1 },
             }
         ]);
     }

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



More information about the Pkg-javascript-commits mailing list