[Pkg-javascript-commits] [node-module-deps] 40/444: only look for package.json transforms when opts.transformKey is set

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:47:41 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 3be114ed43cb49ab79429bd7934a036e78009330
Author: James Halliday <mail at substack.net>
Date:   Wed Feb 27 16:08:59 2013 -0800

    only look for package.json transforms when opts.transformKey is set
---
 index.js          | 10 +++++++---
 test/tr_module.js |  3 ++-
 test/tr_sh.js     |  3 ++-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/index.js b/index.js
index 53310c7..3659f40 100644
--- a/index.js
+++ b/index.js
@@ -40,9 +40,13 @@ module.exports = function (mains, opts) {
         var trx = [];
         parent.packageFilter = function (pkg) {
             if (opts.packageFilter) pkg = opts.packageFilter(pkg);
-            if (pkg.browserify && typeof pkg.browserify === 'object'
-            && pkg.browserify.transform) {
-                trx = [].concat(pkg.browserify.transform);
+            
+            if (opts.transformKey) {
+                var n = pkg;
+                opts.transformKey.forEach(function (key) {
+                    if (n && typeof n === 'object') n = n[key];
+                });
+                trx = [].concat(n).filter(Boolean);
             }
             return pkg;
         };
diff --git a/test/tr_module.js b/test/tr_module.js
index 87f5552..4819243 100644
--- a/test/tr_module.js
+++ b/test/tr_module.js
@@ -6,7 +6,8 @@ var packer = require('browser-pack');
 test('transform', function (t) {
     t.plan(3);
     var p = mdeps(__dirname + '/files/tr_module/main.js', {
-        transform: [ 'insert-aaa', 'insert-bbb' ]
+        transform: [ 'insert-aaa', 'insert-bbb' ],
+        transformKey: [ 'browserify', 'transform' ]
     });
     var pack = packer();
     
diff --git a/test/tr_sh.js b/test/tr_sh.js
index abfee2f..8e778b2 100644
--- a/test/tr_sh.js
+++ b/test/tr_sh.js
@@ -6,7 +6,8 @@ var packer = require('browser-pack');
 test('transform', function (t) {
     t.plan(3);
     var p = mdeps(__dirname + '/files/tr_sh/main.js', {
-        transform: [ 'sed s/AAA/5/', 'sed s/BBB/50/' ]
+        transform: [ 'sed s/AAA/5/', 'sed s/BBB/50/' ],
+        transformKey: [ 'browserify', 'transform' ]
     });
     var pack = packer();
     

-- 
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