[Pkg-javascript-commits] [node-detective] 105/119: remove escodegen and just grab the expr from the src
Bastien Roucariès
rouca at moszumanska.debian.org
Wed Sep 6 09:44:39 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 c388afad0f9702793e25d6493e5c341d7655d70f
Author: Andres Suarez <zertosh at gmail.com>
Date: Sat Oct 31 20:10:17 2015 -0700
remove escodegen and just grab the expr from the src
---
index.js | 8 ++++----
package.json | 3 +--
test/files/both.js | 4 ++--
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/index.js b/index.js
index 0d0be7c..16e1446 100644
--- a/index.js
+++ b/index.js
@@ -1,6 +1,5 @@
var acorn = require('acorn');
var walk = require('acorn/dist/walk');
-var escodegen = require('escodegen');
var defined = require('defined');
var requireRe = /\brequire\b/;
@@ -48,11 +47,12 @@ exports.find = function (src, opts) {
CallExpression: function (node) {
if (!isRequire(node)) return;
if (node.arguments.length) {
- if (node.arguments[0].type === 'Literal') {
- modules.strings.push(node.arguments[0].value);
+ var arg = node.arguments[0];
+ if (arg.type === 'Literal') {
+ modules.strings.push(arg.value);
}
else {
- modules.expressions.push(escodegen.generate(node.arguments[0]));
+ modules.expressions.push(src.slice(arg.start, arg.end));
}
}
if (opts.nodes) modules.nodes.push(node);
diff --git a/package.json b/package.json
index 042a972..11e9452 100644
--- a/package.json
+++ b/package.json
@@ -18,8 +18,7 @@
},
"dependencies": {
"acorn": "^1.0.3",
- "defined": "^1.0.0",
- "escodegen": "^1.4.1"
+ "defined": "^1.0.0"
},
"devDependencies": {
"tap": "^1.0.0"
diff --git a/test/files/both.js b/test/files/both.js
index 4c3f390..74bc521 100644
--- a/test/files/both.js
+++ b/test/files/both.js
@@ -1,4 +1,4 @@
require('a');
require('b');
-require('c'+x);
-var moo = require('d'+y).moo;
+require('c' + x);
+var moo = require('d' + y).moo;
--
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