[Pkg-javascript-commits] [node-detective] 26/119: fix some things

Bastien Roucariès rouca at moszumanska.debian.org
Wed Sep 6 09:44:31 UTC 2017


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

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

commit 1fa42759fbb329a4fef1d57b3f7eca4f7c01d022
Author: James Halliday <mail at substack.net>
Date:   Mon Mar 5 14:17:09 2012 -0800

    fix some things
---
 index.js     | 21 +++++++++++----------
 package.json |  6 +++---
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/index.js b/index.js
index 6e76e2e..d3bfd3f 100644
--- a/index.js
+++ b/index.js
@@ -1,18 +1,20 @@
 var uglify = require('uglify-js');
 
-
 var traverse = function (node, cb) {
     // Call cb on all good AST nodes.
-    if (Array.isArray(node) && node[0] && typeof node[0] === 'object' && node[0].name)
-        cb({name: node[0].name, value: node.slice(1)});
-
+    if (Array.isArray(node) && node[0]
+    && typeof node[0] === 'object' && node[0].name) {
+        cb({ name : node[0].name, value : node.slice(1) });
+    }
+    
     // Traverse down the tree on arrays and objects.
-    if (Array.isArray(node) || Object.prototype.toString.call(node) === "[object Object]")
-        for (var key in node)
-            traverse(node[key], cb);
+    if (Array.isArray(node)
+    || Object.prototype.toString.call(node) === "[object Object]") {
+        for (var key in node) traverse(node[key], cb);
+    }
 };
 
-var process = function (src, cb) {
+var walk = function (src, cb) {
     var ast = uglify.parser.parse(src.toString(), false, true);
     traverse(ast, cb);    
 };
@@ -21,7 +23,6 @@ var deparse = function (ast) {
     return uglify.uglify.gen_code(ast);
 };
 
-
 var exports = module.exports = function (src, opts) {
     return exports.find(src, opts).strings;
 };
@@ -34,7 +35,7 @@ exports.find = function (src, opts) {
     
     if (src.toString().indexOf(word) == -1) return modules;
     
-    process(src, function (node) {
+    walk(src, function (node) {
         var isRequire = node.name === 'call'
             && node.value[0][0] === 'name'
             && node.value[0][1] === word
diff --git a/package.json b/package.json
index ee98ade..f31e1ec 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
     "name" : "detective",
     "description" : "Find all calls to require() no matter how crazily nested using a proper walk of the AST",
-    "version" : "0.0.5",
+    "version" : "0.1.0",
     "repository" : {
         "type" : "git",
         "url" : "git://github.com/substack/node-detective.git"
@@ -22,10 +22,10 @@
         "test" : "expresso"
     },
     "dependencies" : {
-        "uglify-js" : "1.x"
+        "uglify-js" : "~1.2.5"
     },
     "devDependencies" : {
-        "expresso" : "=0.7.x"
+        "expresso" : "0.7.x"
     },
     "engines" : {
         "node" : ">=0.4.0"

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



More information about the Pkg-javascript-commits mailing list