[Pkg-javascript-commits] [node-browser-unpack] 02/40: entries properly work

Bastien Roucariès rouca at moszumanska.debian.org
Thu Nov 9 12:27:23 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-browser-unpack.

commit 7aee2728994cfeed73ce19409661578450a0a272
Author: James Halliday <mail at substack.net>
Date:   Mon Dec 23 20:24:47 2013 -0800

    entries properly work
---
 bin/cmd.js               | 14 ++++++++++++++
 example/rematerialize.js |  6 ------
 index.js                 |  8 ++++++--
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/bin/cmd.js b/bin/cmd.js
new file mode 100755
index 0000000..15e10e7
--- /dev/null
+++ b/bin/cmd.js
@@ -0,0 +1,14 @@
+#!/usr/bin/env node
+
+var parse = require('../');
+var concat = require('concat-stream');
+
+process.stdin.pipe(concat(function (body) {
+    var rows = parse(body);
+    console.log('[');
+    rows.forEach(function (row, index) {
+        if (index > 0) console.log(',');
+        console.log(JSON.stringify(row));
+    });
+    console.log(']');
+}));
diff --git a/example/rematerialize.js b/example/rematerialize.js
deleted file mode 100644
index 79faf28..0000000
--- a/example/rematerialize.js
+++ /dev/null
@@ -1,6 +0,0 @@
-var parse = require('../');
-var concat = require('concat-stream');
-
-process.stdin.pipe(concat(function (body) {
-    console.log(parse(body));
-}));
diff --git a/index.js b/index.js
index 7f97f85..57d597f 100644
--- a/index.js
+++ b/index.js
@@ -15,7 +15,9 @@ module.exports = function (src) {
     
     var files = args[0].properties;
     var cache = args[1];
-    var entries = args[2];
+    var entries = args[2].elements.map(function (e) {
+        return e.value
+    });
     
     return files.map(function (file) {
         var body = file.value.elements[0].body.body;
@@ -34,10 +36,12 @@ module.exports = function (src) {
             acc[dep.key.value] = dep.value.value;
             return acc;
         }, {});
-        return {
+        var row = {
             id: file.key.value,
             source: src.slice(start, end).toString('utf8'),
             deps: deps
         };
+        if (entries.indexOf(row.id) >= 0) row.entry = true;
+        return row;
     });
 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-browser-unpack.git



More information about the Pkg-javascript-commits mailing list