Socket
Socket
Sign inDemoInstall

dependency-tree

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dependency-tree - npm Package Compare versions

Comparing version 6.0.0 to 6.0.1

.babelrc

8

bin/cli.js

@@ -5,4 +5,4 @@ #!/usr/bin/env node

var dependencyTree = require('../');
var program = require('commander');
const dependencyTree = require('../');
const program = require('commander');

@@ -18,5 +18,5 @@ program

var tree;
let tree;
var options = {
const options = {
filename: program.args[0],

@@ -23,0 +23,0 @@ root: program.directory,

@@ -1,8 +0,10 @@

var precinct = require('precinct');
var path = require('path');
var fs = require('fs');
var cabinet = require('filing-cabinet');
var debug = require('debug')('tree');
var Config = require('./lib/Config');
'use strict';
const precinct = require('precinct');
const path = require('path');
const fs = require('fs');
const cabinet = require('filing-cabinet');
const debug = require('debug')('tree');
const Config = require('./lib/Config');
/**

@@ -25,3 +27,3 @@ * Recursively find all dependencies (avoiding circular) traversing the entire dependency tree

module.exports = function(options) {
var config = new Config(options);
const config = new Config(options);

@@ -33,3 +35,3 @@ if (!fs.existsSync(config.filename)) {

var results = traverse(config);
const results = traverse(config);
debug('traversal complete', results);

@@ -40,3 +42,3 @@

var tree;
let tree;
if (config.isListForm) {

@@ -86,4 +88,4 @@ debug('list form of results requested');

module.exports._getDependencies = function(config) {
var dependencies;
var precinctOptions = config.detectiveConfig;
let dependencies;
const precinctOptions = config.detectiveConfig;
precinctOptions.includeCore = false;

@@ -102,8 +104,8 @@

var resolvedDependencies = [];
const resolvedDependencies = [];
for (var i = 0, l = dependencies.length; i < l; i++) {
var dep = dependencies[i];
for (let i = 0, l = dependencies.length; i < l; i++) {
const dep = dependencies[i];
var result = cabinet({
const result = cabinet({
partial: dep,

@@ -124,3 +126,3 @@ filename: config.filename,

var exists = fs.existsSync(result);
const exists = fs.existsSync(result);

@@ -144,3 +146,3 @@ if (!exists) {

function traverse(config) {
var subTree = config.isListForm ? [] : {};
let subTree = config.isListForm ? [] : {};

@@ -154,3 +156,3 @@ debug('traversing ' + config.filename);

var dependencies = module.exports._getDependencies(config);
let dependencies = module.exports._getDependencies(config);

@@ -171,5 +173,5 @@ debug('cabinet-resolved all dependencies: ', dependencies);

for (var i = 0, l = dependencies.length; i < l; i++) {
var d = dependencies[i];
var localConfig = config.clone();
for (let i = 0, l = dependencies.length; i < l; i++) {
const d = dependencies[i];
const localConfig = config.clone();
localConfig.filename = d;

@@ -204,9 +206,9 @@

function removeDups(list) {
var cache = {};
var unique = [];
const cache = new Set();
const unique = [];
list.forEach(function(item) {
if (!cache[item]) {
if (!cache.has(item)) {
unique.push(item);
cache[item] = true;
cache.add(item);
}

@@ -220,8 +222,8 @@ });

function dedupeNonExistent(nonExistent) {
var deduped = removeDups(nonExistent);
const deduped = removeDups(nonExistent);
nonExistent.length = deduped.length;
for (var i = 0, l = deduped.length; i < l; i++) {
for (let i = 0, l = deduped.length; i < l; i++) {
nonExistent[i] = deduped[i];
}
}

@@ -1,33 +0,37 @@

var path = require('path');
var debug = require('debug')('tree');
'use strict';
function Config(options) {
this.filename = options.filename;
this.directory = options.directory || options.root;
this.visited = options.visited || {};
this.nonExistent = options.nonExistent || [];
this.isListForm = options.isListForm;
this.requireConfig = options.config || options.requireConfig;
this.webpackConfig = options.webpackConfig;
this.nodeModulesConfig = options.nodeModulesConfig;
this.detectiveConfig = options.detective || options.detectiveConfig || {};
const path = require('path');
const debug = require('debug')('tree');
this.filter = options.filter;
class Config {
constructor(options) {
this.filename = options.filename;
this.directory = options.directory || options.root;
this.visited = options.visited || {};
this.nonExistent = options.nonExistent || [];
this.isListForm = options.isListForm;
this.requireConfig = options.config || options.requireConfig;
this.webpackConfig = options.webpackConfig;
this.nodeModulesConfig = options.nodeModulesConfig;
this.detectiveConfig = options.detective || options.detectiveConfig || {};
if (!this.filename) { throw new Error('filename not given'); }
if (!this.directory) { throw new Error('directory not given'); }
if (this.filter && typeof this.filter !== 'function') { throw new Error('filter must be a function'); }
this.filter = options.filter;
debug('given filename: ' + this.filename);
if (!this.filename) { throw new Error('filename not given'); }
if (!this.directory) { throw new Error('directory not given'); }
if (this.filter && typeof this.filter !== 'function') { throw new Error('filter must be a function'); }
this.filename = path.resolve(process.cwd(), this.filename);
debug('given filename: ' + this.filename);
debug('resolved filename: ' + this.filename);
debug('visited: ', this.visited);
this.filename = path.resolve(process.cwd(), this.filename);
debug('resolved filename: ' + this.filename);
debug('visited: ', this.visited);
}
clone () {
return new Config(this);
}
}
Config.prototype.clone = function() {
return new Config(this);
};
module.exports = Config;
{
"name": "dependency-tree",
"version": "6.0.0",
"version": "6.0.1",
"description": "Get the dependency tree of a module",
"main": "index.js",
"scripts": {
"test": "jscs index.js test/test.js && ./node_modules/.bin/mocha --compilers js:babel/register test/test.js"
"test": "jscs index.js test/test.js && ./node_modules/.bin/mocha --require babel-core/register test/test.js"
},

@@ -47,6 +47,9 @@ "bin": {

"devDependencies": {
"babel": "~5.8.38",
"jscs": "~2.11.0",
"jscs-preset-mrjoelkemp": "~1.0.0",
"mocha": "^4.1.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-register": "^6.26.0",
"babel-preset-env": "~1.6.1",
"jscs": "^3.0.7",
"jscs-preset-mrjoelkemp": "~2.0.0",
"mocha": "^5.0.0",
"mock-fs": "^4.0.0",

@@ -53,0 +56,0 @@ "resolve": "^1.5.0",

@@ -0,1 +1,3 @@

'use strict';
module.exports = {

@@ -8,2 +10,2 @@ entry: './index.js',

}
};
};
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