[Pkg-javascript-commits] [node-module-deps] 34/444: transform test passes

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:47:40 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 f641af5a01c1b3c293d1bbb3de660ba153ea82f2
Author: James Halliday <mail at substack.net>
Date:   Wed Feb 27 04:29:18 2013 -0800

    transform test passes
---
 index.js | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/index.js b/index.js
index cc501b9..fa9dabc 100644
--- a/index.js
+++ b/index.js
@@ -38,6 +38,15 @@ module.exports = function (mains, opts) {
     function walk (id, parent, cb) {
         pending ++;
         
+        var trx = [];
+        parent.packageFilter = function (pkg) {
+            if (pkg.browserify && typeof pkg.browserify === 'object'
+            && pkg.browserify.transform) {
+                trx = [].concat(pkg.browserify.transform);
+            }
+            return pkg;
+        };
+        
         resolve(id, parent, function (err, file) {
             if (err) return output.emit('error', err);
             if (cb) cb(file);
@@ -46,24 +55,24 @@ module.exports = function (mains, opts) {
             
             fs.readFile(file, 'utf8', function (err, src) {
                 if (err) return output.emit('error', err);
-                
-                applyTransforms(file, src);
+                applyTransforms(file, trx, src);
             });
         });
     }
     
-    function applyTransforms (file, src) {
+    function applyTransforms (file, trx, src) {
+        var isTopLevel = mains.some(function (main) {
+            var m = path.relative(path.dirname(main), file);
+            return m.split('/').indexOf('node_modules') < 0;
+        });
+        var transf = (isTopLevel ? transforms : []).concat(trx);
+        if (transf.length === 0) return done();
+        
         (function ap (trs) {
             if (trs.length === 0) return done();
             var tr = trs[0];
             var cmd = parseShell(tr);
             
-            var isTopLevel = mains.some(function (main) {
-                var m = path.relative(path.dirname(main), file);
-                return m.split('/').indexOf('node_modules') < 0;
-            });
-            if (!isTopLevel) return ap(trs.slice(1));
-            
             var ps = spawn(cmd[0], cmd.slice(1), {
                 cwd: path.dirname(file)
             });
@@ -79,7 +88,7 @@ module.exports = function (mains, opts) {
                 ap(trs.slice(1));
             });
             ps.stdin.end(src);
-        })(transforms.slice());
+        })(transf);
         
         function done () {
             parseDeps(file, src);

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