detective-cjs
Advanced tools
Comparing version 1.0.4 to 1.0.5
11
index.js
@@ -6,3 +6,2 @@ var Walker = require('node-source-walk'); | ||
/** | ||
* [exports description] | ||
* @param {String|Object} content - A file's string content or its AST | ||
@@ -21,9 +20,13 @@ * @return {String[]} The file's dependencies | ||
if (!types.isRequire(node) || !node.arguments || !node.arguments.length) { return; } | ||
if (!types.isRequire(node) || | ||
!node.arguments || | ||
!node.arguments.length) { | ||
return; | ||
} | ||
if (node.arguments[0].type === 'Literal') { | ||
dependency = node.arguments[0].value; | ||
dependency = node.arguments[0].value; | ||
} else { | ||
dependency = escodegen.generate(node.arguments[0]); | ||
dependency = escodegen.generate(node.arguments[0]); | ||
} | ||
@@ -30,0 +33,0 @@ |
{ | ||
"name": "detective-cjs", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Get the dependencies of a CommonJS module by traversing its AST", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha test/test.js" | ||
"test": "jscs -p google index.js test && mocha test/test.js" | ||
}, | ||
@@ -18,3 +18,5 @@ "repository": { | ||
"ast", | ||
"static analysis" | ||
"static analysis", | ||
"cjs", | ||
"jsx" | ||
], | ||
@@ -28,2 +30,3 @@ "author": "Joel Kemp <joel@mrjoelkemp.com>", | ||
"devDependencies": { | ||
"jscs": "~2.4.0", | ||
"mocha": "~2.0.1", | ||
@@ -30,0 +33,0 @@ "sinon": "~1.12.2" |
@@ -7,4 +7,4 @@ #### detective-cjs [![npm](http://img.shields.io/npm/v/detective-cjs.svg)](https://npmjs.org/package/detective-cjs) [![npm](http://img.shields.io/npm/dm/detective-cjs.svg)](https://npmjs.org/package/detective-cjs) | ||
But bro, substack already built this (node-detective). Yes, but I needed the capability to reuse an AST | ||
and this was unlikely to be merged timely. | ||
But brah, substack already built this: node-detective. Yes, but I needed the capability to reuse an AST | ||
and this was unlikely to be merged timely. I can also support jsx and other syntactic constructs faster. | ||
@@ -23,4 +23,6 @@ ### Usage | ||
* Supports JSX and any other features that [node-source-walk](https://github.com/mrjoelkemp/node-source-walk) supports. | ||
#### License | ||
MIT |
@@ -61,2 +61,8 @@ var assert = require('assert'); | ||
}); | ||
it('does not throw on jsx', function() { | ||
assert.doesNotThrow(function() { | ||
detective('var a = require("./foo" + "bar"); var templ = <jsx />'); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4385
88
27
3