dependency-scanner
Advanced tools
Comparing version 1.0.3 to 1.1.0
35
index.js
@@ -21,6 +21,2 @@ #!/usr/bin/env node | ||
var packagePath = path.resolve('package.json'); | ||
loadDependencies(packagePath); | ||
function logMessage(message) { | ||
@@ -34,2 +30,14 @@ // don't log not truthy values, or in silent | ||
function displayDependencies(deps) { | ||
deps.sort().forEach(function (item) { | ||
console.log(item.name); | ||
}) | ||
} | ||
function appendDependencies(arr, deps, depType) { | ||
return (arr || {}).concat(Object.keys(deps).map(function (key) { | ||
return { name: key, version: deps[key], depType }; | ||
})); | ||
} | ||
function loadDependencies(path) { | ||
@@ -43,3 +51,3 @@ return fs.stat(path, function (err, stat) { | ||
logMessage(VERBOSE && 'loading production dependencies'); | ||
deps = deps.concat(Object.keys(pkg.dependencies)); | ||
deps = appendDependencies(deps, pkg.dependencies, 'production'); | ||
} | ||
@@ -49,3 +57,3 @@ | ||
logMessage(VERBOSE && 'loading dev dependencies'); | ||
deps = deps.concat(Object.keys(pkg.devDependencies)); | ||
deps = appendDependencies(deps, pkg.devDependencies, 'dev'); | ||
} | ||
@@ -55,3 +63,3 @@ | ||
logMessage(VERBOSE && 'loading peer dependencies'); | ||
deps = deps.concat(Object.keys(pkg.peerDependencies)); | ||
deps = appendDependencies(deps, pkg.peerDependencies, 'peer'); | ||
} | ||
@@ -62,3 +70,3 @@ | ||
logMessage(VERBOSE && 'loading bundled dependencies'); | ||
deps = deps.concat(Object.keys(pkg.bundledDependencies)); | ||
deps = appendDependencies(deps, pkg.bundledDependencies, 'bundled'); | ||
} | ||
@@ -68,3 +76,3 @@ | ||
logMessage(VERBOSE && 'loading bundle dependencies'); | ||
deps = deps.concat(Object.keys(pkg.bundleDependencies)); | ||
deps = appendDependencies(deps, pkg.bundleDependencies, 'bundled'); | ||
} | ||
@@ -75,3 +83,3 @@ } | ||
logMessage(VERBOSE && 'loading optional dependencies'); | ||
deps = deps.concat(Object.keys(pkg.optionalDependencies)); | ||
deps = appendDependencies(deps, pkg.optionalDependencies, 'optional'); | ||
} | ||
@@ -92,6 +100,3 @@ | ||
function displayDependencies(deps) { | ||
deps.sort().forEach(function (item) { | ||
console.log(item); | ||
}) | ||
} | ||
var packagePath = path.resolve('package.json'); | ||
loadDependencies(packagePath); |
{ | ||
"name": "dependency-scanner", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "Outputs dependancies from package.json provided", | ||
@@ -5,0 +5,0 @@ "files": [ |
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
3906
80