Socket
Socket
Sign inDemoInstall

detective-typescript

Package Overview
Dependencies
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detective-typescript - npm Package Compare versions

Comparing version 5.6.1 to 5.7.0

37

index.js

@@ -5,2 +5,3 @@ 'use strict';

const Walker = require('node-source-walk');
const types = require('ast-module-types');

@@ -23,2 +24,5 @@ /**

const mixedImports = Boolean(options.mixedImports);
delete walkerOptions.mixedImports;
const walker = new Walker(walkerOptions);

@@ -64,2 +68,19 @@

break;
case 'CallExpression':
if (!mixedImports || !types.isRequire(node) ||
!node.arguments ||
!node.arguments.length) {
break;
}
if (types.isPlainRequire(node)) {
const result = extractDependencyFromRequire(node);
if (result) {
dependencies.push(result);
}
} else if (types.isMainScopedRequire(node)) {
dependencies.push(extractDependencyFromMainRequire(node));
}
break;
default:

@@ -73,4 +94,16 @@ return;

module.exports.tsx = function(src, options = {jsx: true}) {
return module.exports(src, options);
module.exports.tsx = function(src, options) {
return module.exports(src, Object.assign({}, options, { jsx: true }));
};
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;
}

3

package.json
{
"name": "detective-typescript",
"version": "5.6.1",
"version": "5.7.0",
"author": "Patrik Henningsson <patrik.henningsson@gmail.com>",

@@ -29,2 +29,3 @@ "description": "Get the dependencies of a TypeScript module",

"@typescript-eslint/typescript-estree": "^2.4.0",
"ast-module-types": "^2.5.0",
"node-source-walk": "^4.2.0",

@@ -31,0 +32,0 @@ "typescript": "^3.6.4"

@@ -19,4 +19,9 @@ ### detective-typescript [![Build Status](http://img.shields.io/travis/pahen/detective-typescript/master.svg?style=flat-square)](https://travis-ci.org/pahen/detective-typescript) [![npm](http://img.shields.io/npm/v/detective-typescript.svg)](https://npmjs.org/package/detective-typescript) [![npm](http://img.shields.io/npm/dm/detective-typescript.svg)](https://npmjs.org/package/detective-typescript)

### Options
- `skipTypeImports` (default: false) - Skips imports that only imports types
- `mixedImports`: (default: false) - Include CJS imports in dependency list
#### License
MIT
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