snyk-resolve-deps
Advanced tools
Comparing version 4.2.0 to 4.3.0
@@ -113,7 +113,7 @@ "use strict"; | ||
return fs.readdir(path.resolve(root, 'node_modules')).then(function (dirs) { | ||
let res = dirs.map(function (dir) { | ||
let res = dirs.map(function (directory) { | ||
// completely ignore `.bin` npm helper dir | ||
// ~ can be a symlink to node_modules itself | ||
// (https://www.npmjs.com/package/link-tilde) | ||
if (['.bin', '.DS_Store', '~'].indexOf(dir) >= 0) { | ||
if (['.bin', '.DS_Store', '~'].indexOf(directory) >= 0) { | ||
return null; | ||
@@ -123,8 +123,8 @@ } | ||
// inside *this* `dir`, so treat differently | ||
if (dir.indexOf('@') === 0) { | ||
debug('scoped reset on %s', dir); | ||
dir = path.resolve(root, 'node_modules', dir); | ||
return fs.readdir(dir).then(function (dirs) { | ||
return Promise.all(dirs.map(function (scopedDir) { | ||
return tryRequire(path.resolve(dir, scopedDir, 'package.json')); | ||
if (directory.indexOf('@') === 0) { | ||
debug('scoped reset on %s', directory); | ||
directory = path.resolve(root, 'node_modules', directory); | ||
return fs.readdir(directory).then(function (directories) { | ||
return Promise.all(directories.map(function (scopedDir) { | ||
return tryRequire(path.resolve(directory, scopedDir, 'package.json')); | ||
})); | ||
@@ -134,17 +134,17 @@ }); | ||
// otherwise try to load a package.json from this node_module dir | ||
dir = path.resolve(root, 'node_modules', dir, 'package.json'); | ||
return tryRequire(dir); | ||
directory = path.resolve(root, 'node_modules', directory, 'package.json'); | ||
return tryRequire(directory); | ||
}); | ||
return Promise.all(res).then(function (res) { | ||
res = _.flatten(res).filter(Boolean); | ||
return Promise.all(res).then(function (response) { | ||
response = _.flatten(response).filter(Boolean); | ||
// if res.length === 0 we used to throw MISSING_NODE_MODULES but we're | ||
// not doing that now, and I think it's okay. | ||
// TODO: convert reduces to more readable code throughout | ||
res.reduce(function (acc, curr) { | ||
response.reduce(function (acc, curr) { | ||
let license; | ||
let licenses = curr.license || curr.licenses; | ||
if (Array.isArray(licenses)) { | ||
license = licenses.reduce(function (acc, curr) { | ||
acc.push((curr || {}).type || curr); | ||
return acc; | ||
license = licenses.reduce(function (accumulator, current) { | ||
accumulator.push((current || {}).type || current); | ||
return accumulator; | ||
}, []).join('/'); | ||
@@ -191,14 +191,14 @@ } | ||
}); | ||
}).then(function (modules) { | ||
let deps = Object.keys(modules.dependencies); | ||
}).then(function (mods) { | ||
let deps = Object.keys(mods.dependencies); | ||
let promises = deps.map(function (dep) { | ||
let depType = modules.dependencies[dep].depType; | ||
let dir = path.dirname(modules.dependencies[dep].__filename); | ||
return loadModulesInternal(dir, depType, pkg); | ||
let depType = mods.dependencies[dep].depType; | ||
let directory = path.dirname(mods.dependencies[dep].__filename); | ||
return loadModulesInternal(directory, depType, pkg); | ||
}); | ||
return Promise.all(promises).then(function (res) { | ||
res.forEach(function (mod) { | ||
modules.dependencies[mod.name].dependencies = mod.dependencies; | ||
mods.dependencies[mod.name].dependencies = mod.dependencies; | ||
}); | ||
return modules; | ||
return mods; | ||
}); | ||
@@ -205,0 +205,0 @@ }).catch(function (error) { |
@@ -56,4 +56,4 @@ "use strict"; | ||
let deppath = dep.__from.slice(0, -1).toString(); | ||
let removed = removedPaths.filter(function (path) { | ||
return deppath.indexOf(path) === 0; | ||
let removed = removedPaths.filter(function (removedPath) { | ||
return deppath.indexOf(removedPath) === 0; | ||
}).length; | ||
@@ -70,5 +70,5 @@ if (removed) { | ||
leaf.dependencies = walkDeps(fileTree, dep, undefined, problems); | ||
walk(leaf.dependencies, function (dep) { | ||
dep.extraneous = true; | ||
dep.depType = depTypes.EXTRANEOUS; | ||
walk(leaf.dependencies, function (extraDep) { | ||
extraDep.extraneous = true; | ||
extraDep.depType = depTypes.EXTRANEOUS; | ||
}); | ||
@@ -89,9 +89,9 @@ insertLeaf(logicalRoot, leaf, dep.__from); | ||
// remove the root of the path and covert to names only | ||
let path = (from || []).slice(1, -1).map(function (pkg) { | ||
let leafPath = (from || []).slice(1, -1).map(function (pkg) { | ||
return moduleToObject(pkg).name; | ||
}); | ||
let entry = tree.dependencies; | ||
for (let i = 0; i < path.length; i++) { | ||
if (entry[path[i]]) { | ||
entry = entry[path[i]].dependencies; | ||
for (let i = 0; i < leafPath.length; i++) { | ||
if (entry[leafPath[i]]) { | ||
entry = entry[leafPath[i]].dependencies; | ||
} | ||
@@ -98,0 +98,0 @@ } |
@@ -60,3 +60,3 @@ { | ||
}, | ||
"version": "4.2.0" | ||
"version": "4.3.0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48094