Socket
Socket
Sign inDemoInstall

detective-cjs

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detective-cjs - npm Package Compare versions

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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc