mr-dep-walk
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -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', | ||
]); | ||
}); | ||
}); | ||
}); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
21602
344
1