Socket
Socket
Sign inDemoInstall

mr-dep-walk

Package Overview
Dependencies
6
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.2.0

9

lib/dep-files-from-file.js

@@ -10,3 +10,4 @@ 'use strict';

let file = options.entry;
let deps = depsFromFile(path.join(root, file));
let cwd = options.cwd || '';
let deps = depsFromFile(path.join(root, cwd, file));

@@ -17,2 +18,3 @@ for (let i = 0; i < deps.length; i++) {

let dependency = resolved + '.js';
let fullDependency = cwd ? cwd + '/' + dependency : dependency;

@@ -23,5 +25,6 @@ if (Array.isArray(options.external) && options.external.indexOf(resolved) > -1) {

if (files.indexOf(dependency) === -1) {
files.push(dependency);
if (files.indexOf(fullDependency) === -1) {
files.push(fullDependency);
depFilesFromFile(root, {
cwd: cwd,
entry: dependency,

@@ -28,0 +31,0 @@ external: options.external

@@ -17,3 +17,3 @@ {

"name": "mr-dep-walk",
"version": "1.1.2",
"version": "1.2.0",
"main": "index.js",

@@ -20,0 +20,0 @@ "directories": {

@@ -120,2 +120,46 @@ 'use strict';

});
describe('cwd', function() {
beforeEach(function() {
fs.removeSync(ROOT);
fixturify.writeSync(ROOT + 'cwd/foo', {
'foo.js': `
import x from 'a';
import y from 'b/c';`,
'a.js': ``,
'b': {
'c.js': `
import a from '../a';
import d from '../d';
`
},
'd.js': `import foo from 'foo';`
});
});
it('extracts', function() {
expect(depFilesFromFile(ROOT + 'cwd', { entry: 'foo.js', cwd: 'foo' })).to.eql([
'foo/a.js',
'foo/b/c.js',
'foo/d.js',
'foo/foo.js',
]);
expect(depFilesFromFile(ROOT + 'cwd', { entry: 'a.js', cwd: 'foo' })).to.eql([]);
expect(depFilesFromFile(ROOT + 'cwd', { entry: 'b/c.js', cwd: 'foo' })).to.eql([
'foo/a.js',
'foo/d.js',
'foo/foo.js',
'foo/b/c.js',
]);
expect(depFilesFromFile(ROOT + 'cwd', { entry: 'd.js', cwd: 'foo' })).to.eql([
'foo/foo.js',
'foo/a.js',
'foo/b/c.js',
'foo/d.js',
]);
});
});
});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc