'use strict' var validate = require('aproba') var asyncMap = require('slide').asyncMap var chain = require('slide').chain var npmInstallChecks = require('npm-install-checks') var iferr = require('iferr') var checkEngine = npmInstallChecks.checkEngine var checkPlatform = npmInstallChecks.checkPlatform var npm = require('../npm.js') module.exports = function (idealTree, args, next) { validate('OAF', arguments) var force = npm.config.get('force') asyncMap(args, function (pkg, done) { chain([ [hasMinimumFields, pkg], [checkSelf, idealTree, pkg, force], [isInstallable, idealTree, pkg] ], done) }, next) } function hasMinimumFields (pkg, cb) { if (pkg.name === '' || pkg.name == null) { return cb(new Error(`Can't install ${pkg._resolved}: Missing package name`)) } else if (pkg.version === '' || pkg.version == null) { return cb(new Error(`Can't install ${pkg._resolved}: Missing package version`)) } else { return cb() } } function setWarnings (idealTree, warn) { function top (tree) { if (tree.parent) return top(tree.parent) return tree } var topTree = top(idealTree) if (!topTree.warnings) topTree.warnings = [] if (topTree.warnings.every(i => ( i.code !== warn.code || i.required !== warn.required || i.pkgid !== warn.pkgid))) { topTree.warnings.push(warn) } } var isInstallable = module.exports.isInstallable = function (idealTree, pkg, next) { var force = npm.config.get('force') var nodeVersion = npm.config.get('node-version') if (/-/.test(nodeVersion)) { // for the purposes of validation, if the node version is a prerelease, // strip that. We check and warn about this sceanrio over in validate-tree. nodeVersion = nodeVersion.replace(/-.*/, '') } var strict = npm.config.get('engine-strict') checkEngine(pkg, npm.version, nodeVersion, force, strict, iferr(next, thenWarnEngineIssues)) function thenWarnEngineIssues (warn) { if (idealTree && warn) setWarnings(idealTree, warn) checkPlatform(pkg, force, next) } } function checkSelf (idealTree, pkg, force, next) { if (idealTree.package && idealTree.package.name !== pkg.name) return next() if (force) { var warn = new Error("Wouldn't install " + pkg.name + ' as a dependency of itself, but being forced') warn.code = 'ENOSELF' idealTree.warnings.push(warn) next() } else { var er = new Error('Refusing to install package with name "' + pkg.name + '" under a package\n' + 'also called "' + pkg.name + '". Did you name your project the same\n' + 'as the dependency you\'re installing?\n\n' + 'For more information, see:\n' + ' <https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm>') er.code = 'ENOSELF' next(er) } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
action | Folder | 0755 |
|
|
access-error.js | File | 202 B | 0644 |
|
actions.js | File | 5.52 KB | 0644 |
|
and-add-parent-to-errors.js | File | 375 B | 0644 |
|
and-finish-tracker.js | File | 360 B | 0644 |
|
and-ignore-errors.js | File | 204 B | 0644 |
|
audit.js | File | 8.24 KB | 0644 |
|
check-permissions.js | File | 1.85 KB | 0644 |
|
copy-tree.js | File | 770 B | 0644 |
|
decompose-actions.js | File | 2.18 KB | 0644 |
|
deps.js | File | 30.32 KB | 0644 |
|
diff-trees.js | File | 9.12 KB | 0644 |
|
exists.js | File | 775 B | 0644 |
|
flatten-tree.js | File | 1021 B | 0644 |
|
fund.js | File | 1.28 KB | 0644 |
|
get-requested.js | File | 635 B | 0644 |
|
has-modern-meta.js | File | 702 B | 0644 |
|
inflate-bundled.js | File | 628 B | 0644 |
|
inflate-shrinkwrap.js | File | 8.87 KB | 0644 |
|
is-dev-dep.js | File | 175 B | 0644 |
|
is-extraneous.js | File | 618 B | 0644 |
|
is-fs-access-available.js | File | 763 B | 0644 |
|
is-only-dev.js | File | 1.24 KB | 0644 |
|
is-only-optional.js | File | 674 B | 0644 |
|
is-opt-dep.js | File | 185 B | 0644 |
|
is-prod-dep.js | File | 172 B | 0644 |
|
module-staging-path.js | File | 259 B | 0644 |
|
mutate-into-logical-tree.js | File | 4.52 KB | 0644 |
|
node.js | File | 1.85 KB | 0644 |
|
read-shrinkwrap.js | File | 3.67 KB | 0644 |
|
realize-shrinkwrap-specifier.js | File | 621 B | 0644 |
|
report-optional-failure.js | File | 1.02 KB | 0644 |
|
save.js | File | 5.91 KB | 0644 |
|
update-package-json.js | File | 1.87 KB | 0644 |
|
validate-args.js | File | 2.73 KB | 0644 |
|
validate-tree.js | File | 3.1 KB | 0644 |
|
writable.js | File | 1 KB | 0644 |
|