[Pkg-javascript-commits] [node-module-deps] 200/444: re-enable streams, first test passes

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:47:55 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 d062a7ea485d09c57bce80e4d9a0a045de95d1a6
Author: James Halliday <mail at substack.net>
Date:   Fri May 9 00:47:18 2014 -0700

    re-enable streams, first test passes
---
 index.js | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/index.js b/index.js
index b8d796e..4629927 100644
--- a/index.js
+++ b/index.js
@@ -62,7 +62,6 @@ Deps.prototype._start = function () {
         var main = this.mains[i];
         var file = this.entries[i];
         
-        var id = path.resolve(this.basedir, main);
         this.lookupPackage(file, function (err, pkg) {
             if (err) return self.emit('error', err)
             else start(main, file, pkg)
@@ -86,7 +85,10 @@ Deps.prototype.add = function (main) {
     var file;
     if (typeof main.pipe === 'function') {
         var n = Math.floor(Math.pow(16,8) * Math.random()).toString(16);
-        file = path.join(basedir, 'fake_' + n + '.js');
+        file = path.join(this.basedir, 'fake_' + n + '.js');
+        if (typeof main.read !== 'function') {
+            main = Readable().wrap(main);
+        }
     }
     else file = main;
     file = path.resolve(file);
@@ -98,10 +100,10 @@ Deps.prototype.resolve = function (id, parent, cb) {
     var self = this;
     var opts = self.options;
     
-    /*
     if (typeof id === 'object') {
-        id.stream.pipe(concat({ encoding: 'string' }, function (src) {
-            var pkgfile = path.join(basedir, 'package.json');
+        id.stream.pipe(concat(function (body) {
+            var src = body.toString('utf8');
+            var pkgfile = path.join(self.basedir, 'package.json');
             fs.readFile(pkgfile, function (err, pkgsrc) {
                 var pkg = {};
                 if (!err) {
@@ -115,8 +117,7 @@ Deps.prototype.resolve = function (id, parent, cb) {
         if (cb) cb(false);
         return;
     }
-    */
-     
+    
     var c = this.cache && this.cache[parent.id];
     var resolver = c && typeof c === 'object'
     && !Buffer.isBuffer(c) && c.deps[id]
@@ -256,6 +257,16 @@ Deps.prototype.walk = function (id, parent, cb) {
     var opts = self.options;
     this.pending ++;
     
+    if (id && typeof id === 'object' && id.stream) {
+        return id.stream.pipe(concat(function (body) {
+            var src = body.toString('utf8');
+            var deps = self.parseDeps(id.file, src);
+            self.lookupPackage(id.file, function (err, pkg) {
+                fromDeps(id.file, src, pkg || {}, deps);
+            });
+        }));
+    }
+    
     self.resolve(id, parent, function (err, file, pkg) {
         if (err) return self.emit('error', err);
         self.readFile(file).pipe(concat(function (body) {

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