[Pkg-javascript-commits] [node-module-deps] 44/444: take out command version of transforms, only use module form

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 61b813011a6809d0c2b385d2ded125cde49dfe16
Author: James Halliday <mail at substack.net>
Date:   Wed Feb 27 16:56:20 2013 -0800

    take out command version of transforms, only use module form
---
 index.js | 36 +++++-------------------------------
 1 file changed, 5 insertions(+), 31 deletions(-)

diff --git a/index.js b/index.js
index cc30219..34d0ca0 100644
--- a/index.js
+++ b/index.js
@@ -121,47 +121,21 @@ module.exports = function (mains, opts) {
     }
     
     function makeTransform (file, tr) {
-        if (/\s/.test(tr)) return cmdTransform(file, tr);
-        
         var tout = through(), tin = through();
         tin.pause();
         
         var params = { basedir: path.dirname(file) };
         nodeResolve(tr, params, function (err, res) {
             if (err) return output.emit('error', err);
-            var t = res
-                ? require(res)(file)
-                : cmdTransform(file, tr)
-            ;
+            if (!res) return output.emit('error', [
+                'cannot find transform module ', tr,
+                ' while transforming ', file
+            ].join(''));
+            var t = require(res)(file);
             t.pipe(tout);
             tin.pipe(t);
             tin.resume();
         });
         return duplexer(tin, tout);
     }
-    
-    function cmdTransform (file, tr) {
-        var cmd = parseShell(tr);
-        var env = Object.create(process.env);
-        env._ = tr;
-        env.FILENAME = file;
-        var current = { id: file, filename: file, paths: [] };
-        
-        var ps = spawn(cmd[0], cmd.slice(1), {
-            cwd: path.dirname(file),
-            env: env
-        });
-        var error = '';
-        ps.stderr.on('data', function (buf) { error += buf });
-        ps.on('close', function (code) {
-            if (code !== 0) {
-                return output.emit('error', [
-                    'process ' + tr + ' exited with code ' + code,
-                    ' while parsing ' + file + '\n',
-                    error.split('\n').join('\n    ')
-                ].join(''));
-            }
-        });
-        return duplexer(ps.stdin, ps.stdout);
-    }
 };

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