Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

commonjs-walker

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commonjs-walker - npm Package Compare versions

Comparing version 4.1.0 to 5.0.0

38

index.js

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

var resolve = require('resolve');
var EE = require('events').EventEmitter;

@@ -40,3 +41,3 @@ function walker (entry, options, callback) {

makeDefault(options, 'detectCyclic', true);
makeDefault(options, 'allowCyclic', true);
makeDefault(options, 'strictRequire', true);

@@ -51,5 +52,5 @@ makeDefault(options, 'allowAbsolutePath', true);

this.callback = callback;
this._walk();
}
util.inherits(Walker, EE);

@@ -70,3 +71,3 @@ // Checks if the `options.extensions` is valid

Walker.prototype._walk = function() {
Walker.prototype.walk = function() {
var self = this;

@@ -159,4 +160,4 @@ var entry = this.entry;

if (dep.indexOf('/') === 0 && !options.allowAbsolutePath) {
return done({
if (dep.indexOf('/') === 0) {
var message = {
code: 'NOT_ALLOW_ABSOLUTE_PATH',

@@ -168,3 +169,9 @@ message: 'Requiring an absolute path "' + dep + '" is not allowed in "' + path + '"',

}
});
};
if (!options.allowAbsolutePath) {
return done();
} else {
self.emit('warn', message);
}
}

@@ -254,9 +261,5 @@

var circular_trace;
if (
this.options.detectCyclic
// node -> sub_node
&& (circular_trace = circular.trace(sub_node, node, this.nodes))
) {
return callback({
// node -> sub_node
if (circular_trace = circular.trace(sub_node, node, this.nodes)) {
var message = {
code: 'CYCLIC_DEPENDENCY',

@@ -268,3 +271,9 @@ message: 'Cyclic dependency found: \n' + this._printCyclic(circular_trace),

}
});
};
if (!this.options.allowCyclic) {
return callback(message);
} else {
this.emit('warn', message);
}
}

@@ -285,2 +294,3 @@ callback(null);

node = this.nodes[id] = {
id: id,
dependents: [],

@@ -287,0 +297,0 @@ entry: id === this.entry,

{
"name": "commonjs-walker",
"version": "4.1.0",
"version": "5.0.0",
"description": "Analyzer and tree walker for commonjs.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -89,3 +89,3 @@ # commonjs-walker [![NPM version](https://badge.fury.io/js/commonjs-walker.png)](http://badge.fury.io/js/commonjs-walker) [![Build Status](https://travis-ci.org/kaelzhang/node-commonjs-walker.png?branch=master)](https://travis-ci.org/kaelzhang/node-commonjs-walker)

------ | ---- | ------- | ------------
detectCyclic | `Boolean` | true | whether should check cyclic dependencies
allowCyclic | `Boolean` | true | whether should check cyclic dependencies
strictRequire | `Boolean` | true | whether should check the usage of method `require()`. If true, the argument of `require()` must be an literal string.

@@ -116,3 +116,3 @@ allowAbsolutePath | `Boolean` | true | whether should allow to require an absolute path.

{
detectCyclic: true,
allowCyclic: false,
strictRequire: true,

@@ -119,0 +119,0 @@ allowAbsolutePath: false,

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

file: 'circular/index.js',
options: {
allowCyclic: false
},
expect: function (err, path, nodes, entry) {

@@ -41,3 +44,3 @@ expect(err).not.to.equal(null);

options: {
detectCyclic: false
allowCyclic: true
},

@@ -280,5 +283,5 @@ file: 'circular/index.js',

if (noOptions) {
walker(file, callback);
walker(file, callback).walk();
} else {
walker(file, options, callback);
walker(file, options, callback).walk();
}

@@ -285,0 +288,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