[Pkg-javascript-commits] [node-detective] 20/119: Removed hard coded reference to `require`

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 4abd48b0730058b2b3ff9d226eae61f95c3813b2
Author: Raynos <raynos2 at gmail.com>
Date:   Fri Nov 25 18:29:41 2011 +0000

    Removed hard coded reference to `require`
---
 index.js | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/index.js b/index.js
index 5007e02..ba0d287 100644
--- a/index.js
+++ b/index.js
@@ -1,4 +1,5 @@
 var burrito = require('burrito');
+var word = 'require';
 
 var exports = module.exports = function (src) {
     return exports.find(src).strings;
@@ -7,12 +8,12 @@ var exports = module.exports = function (src) {
 exports.find = function (src) {
     var modules = { strings : [], expressions : [] };
     
-    if (src.toString().indexOf('require') == -1) return modules;
+    if (src.toString().indexOf(word) == -1) return modules;
     
     burrito(src, function (node) {
         var isRequire = node.name === 'call'
             && node.value[0][0] === 'name'
-            && node.value[0][1] === 'require'
+            && node.value[0][1] === word
         ;
         if (isRequire) {
             var expr = node.value[1][0];
@@ -28,7 +29,7 @@ exports.find = function (src) {
         var isDotRequire = (node.name === 'dot' || node.name === 'call')
             && node.value[0][0] === 'call'
             && node.value[0][1][0] === 'name'
-            && node.value[0][1][1] === 'require'
+            && node.value[0][1][1] === word
         ;
         
         if (isDotRequire) {
@@ -45,7 +46,7 @@ exports.find = function (src) {
             && node.value[0][0] === 'dot'
             && node.value[0][1][0] === 'call'
             && node.value[0][1][1][0] === 'name'
-            && node.value[0][1][1][1] === 'require'
+            && node.value[0][1][1][1] === word
         ;
         if (isDotCallRequire) {
             var expr = node.value[0][1][2][0];
@@ -60,3 +61,7 @@ exports.find = function (src) {
     
     return modules;
 };
+
+exports.set = function (value) {
+    word = value;  
+};

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