[Pkg-javascript-commits] [node-detective] 09/119: post-dotted requires now pass their test
Bastien Roucariès
rouca at moszumanska.debian.org
Wed Sep 6 09:44:30 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 5d7a0a563c050088af3a7d5f5eaba2528746d571
Author: James Halliday <mail at substack.net>
Date: Sun Jun 19 18:02:07 2011 -0700
post-dotted requires now pass their test
---
index.js | 17 +++++++++++++++++
test/files/strings.js | 5 +++++
test/strings.js | 2 +-
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/index.js b/index.js
index 63729a0..f7af476 100644
--- a/index.js
+++ b/index.js
@@ -22,6 +22,23 @@ exports.find = function (src) {
modules.expressions.push(burrito.deparse(expr));
}
}
+
+ var isDotRequire = node.name === 'dot'
+ && node.value[0][0] === 'call'
+ && node.value[0][1][0] === 'name'
+ && node.value[0][1][1] === 'require'
+ ;
+
+ if (isDotRequire) {
+ var expr = node.value[0][2][0];
+ if (expr[0].name === 'string') {
+ modules.strings.push(expr[1]);
+ }
+ else {
+ modules.expressions.push(burrito.deparse(expr));
+ }
+ }
});
+
return modules;
};
diff --git a/test/files/strings.js b/test/files/strings.js
index 14a7dae..149a310 100644
--- a/test/files/strings.js
+++ b/test/files/strings.js
@@ -1,4 +1,9 @@
var a = require('a');
var b = require('b');
var c = require('c');
+var abc = a.b(c);
+
var EventEmitter = require('events').EventEmitter;
+
+var x = require('doom')(5,6,7);
+var y = require('y') * 100;
diff --git a/test/strings.js b/test/strings.js
index 5a1400d..1ae74b7 100644
--- a/test/strings.js
+++ b/test/strings.js
@@ -4,5 +4,5 @@ var fs = require('fs');
var src = fs.readFileSync(__dirname + '/files/strings.js');
exports.single = function () {
- assert.deepEqual(detective(src), [ 'a', 'b', 'c', 'events' ]);
+ assert.deepEqual(detective(src), [ 'a', 'b', 'c', 'events', 'y' ]);
};
--
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