[Pkg-javascript-commits] [node-module-deps] 174/444: passing transform options implementation

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:47:53 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 19e27b5ea32d6479ed9ea09eb076ed30d361d6b2
Author: James Halliday <mail at substack.net>
Date:   Sun Feb 9 14:30:23 2014 -0800

    passing transform options implementation
---
 index.js                               | 19 +++++++++++++------
 test/tr_opts.js                        |  4 +---
 test/tr_opts/node_modules/fff/index.js |  2 +-
 test/tr_opts/node_modules/ggg/index.js |  2 +-
 4 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/index.js b/index.js
index dda347c..422ab74 100644
--- a/index.js
+++ b/index.js
@@ -199,10 +199,16 @@ module.exports = function (mains, opts) {
         
         (function ap (trs) {
             if (trs.length === 0) return done();
-            makeTransform(file, trs[0], function f (err, s) {
+            var tr = trs[0], trOpts = {};
+            if (Array.isArray(tr)) {
+                trOpts = tr[1];
+                tr = tr[0];
+            }
+            
+            makeTransform(file, [ tr, trOpts ], function f (err, s) {
                 if (err && pkg && pkg.__dirname) {
-                    var t = path.resolve(pkg.__dirname, trs[0]);
-                    return makeTransform(file, t, function (e, s_) {
+                    var t = path.resolve(pkg.__dirname, tr);
+                    return makeTransform(file, [ t, trOpts ], function (e, s_) {
                         if (e) output.emit('error', e);
                         else f(null, s_);
                     });
@@ -276,8 +282,9 @@ module.exports = function (mains, opts) {
         }
     }
     
-    function makeTransform (file, tr, cb) {
-        if (typeof tr === 'function') return cb(null, tr(file));
+    function makeTransform (file, tpair, cb) {
+        var tr = tpair[0], trOpts = tpair[1];
+        if (typeof tr === 'function') return cb(null, tr(file, trOpts));
         
         var params = { basedir: path.dirname(file) };
         nodeResolve(tr, params, function nr (err, res, again) {
@@ -301,7 +308,7 @@ module.exports = function (mains, opts) {
                 return cb(new Error('transform not a function'));
             }
             
-            var trs = r(file);
+            var trs = r(file, trOpts);
             output.emit('transform', trs, file);
             cb(null, trs);
         });
diff --git a/test/tr_opts.js b/test/tr_opts.js
index f0b0048..2b4728d 100644
--- a/test/tr_opts.js
+++ b/test/tr_opts.js
@@ -13,9 +13,7 @@ test('transform options', function (t) {
     
     p.pipe(JSONStream.stringify()).pipe(pack).pipe(concat(function (src) {
         Function('console', src.toString('utf8'))({
-            log: function (msg) {
-                t.equal(msg, 333);
-            }
+            log: function (msg) { t.equal(msg, 333) }
         });
     }));
 });
diff --git a/test/tr_opts/node_modules/fff/index.js b/test/tr_opts/node_modules/fff/index.js
index 8a0f5ba..5bf591d 100644
--- a/test/tr_opts/node_modules/fff/index.js
+++ b/test/tr_opts/node_modules/fff/index.js
@@ -11,7 +11,7 @@ module.exports = function (file, opts) {
     
     function end () {
         var str = Buffer.concat(bufs).toString('utf8');
-        this.queue(str.replace(/FFF/g, opts.f));
+        this.queue(str.replace(/FFF/g, opts.x));
         this.queue(null);
     }
 };
diff --git a/test/tr_opts/node_modules/ggg/index.js b/test/tr_opts/node_modules/ggg/index.js
index fc052e9..f57764a 100644
--- a/test/tr_opts/node_modules/ggg/index.js
+++ b/test/tr_opts/node_modules/ggg/index.js
@@ -11,7 +11,7 @@ module.exports = function (file, opts) {
     
     function end () {
         var str = Buffer.concat(bufs).toString('utf8');
-        this.queue(str.replace(/GGG/g, opts.g));
+        this.queue(str.replace(/GGG/g, opts.z));
         this.queue(null);
     }
 };

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