Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

**WIP** install: correctly exclude dev dependencies when using global and shrinkwrap #218

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/install/is-only-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ const moduleName = require('../utils/module-name.js')
const isDevDep = require('./is-dev-dep.js')
const isProdDep = require('./is-prod-dep.js')

// Returns true if the module `node` is only required direcctly as a dev
// Returns true if the module `node` is only required directly as a dev
// dependency of the top level or transitively _from_ top level dev
// dependencies.
// Dual mode modules (that are both dev AND prod) should return false.
function isOnlyDev (node, seen) {
if (!seen) seen = new Set()
return node.requiredBy.length && node.requiredBy.every(andIsOnlyDev(moduleName(node), seen))
const isRequired = node.requiredBy.length > 0
const isTranstiveDependency = isRequired && node.requiredBy.every(andIsOnlyDev(moduleName(node), seen))
return isTranstiveDependency || !isRequired
}

// There is a known limitation with this implementation: If a dependency is
Expand Down