detective-cjs
Advanced tools
Comparing version 3.0.0 to 3.1.0
23
index.js
@@ -22,9 +22,8 @@ 'use strict'; | ||
if (node.arguments[0].type === 'Literal' || node.arguments[0].type === 'StringLiteral') { | ||
const dependency = node.arguments[0].value; | ||
dependencies.push(dependency); | ||
} else if (node.arguments[0].type === 'TemplateLiteral') { | ||
const dependency = node.arguments[0].quasis[0].value.raw; | ||
dependencies.push(dependency); | ||
if (types.isPlainRequire(node)) { | ||
dependencies.push(extractDependencyFromRequire(node)); | ||
} else if (types.isMainScopedRequire(node)) { | ||
dependencies.push(extractDependencyFromMainRequire(node)); | ||
} | ||
}); | ||
@@ -34,1 +33,13 @@ | ||
}; | ||
function extractDependencyFromRequire(node) { | ||
if (node.arguments[0].type === 'Literal' || node.arguments[0].type === 'StringLiteral') { | ||
return node.arguments[0].value; | ||
} else if (node.arguments[0].type === 'TemplateLiteral') { | ||
return node.arguments[0].quasis[0].value.raw; | ||
} | ||
} | ||
function extractDependencyFromMainRequire(node) { | ||
return node.arguments[0].value; | ||
} |
{ | ||
"name": "detective-cjs", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Get the dependencies of a CommonJS module by traversing its AST", | ||
@@ -32,4 +32,4 @@ "main": "index.js", | ||
"devDependencies": { | ||
"jscs": "~2.4.0", | ||
"jscs-preset-mrjoelkemp": "~1.0.0", | ||
"jscs": "^3.0.7", | ||
"jscs-preset-mrjoelkemp": "~2.0.0", | ||
"mocha": "^5.2.0", | ||
@@ -39,5 +39,5 @@ "sinon": "^6.1.5" | ||
"dependencies": { | ||
"ast-module-types": "^2.3.2", | ||
"ast-module-types": "^2.4.0", | ||
"node-source-walk": "^4.0.0" | ||
} | ||
} |
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
2923
34
Updatedast-module-types@^2.4.0