verify-dependencies.js 716 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. var matchdep = require('matchdep');
  3. /**
  4. * Given a collection of plugin names verifies this collection against
  5. * the blacklist. Returns an object with:
  6. * [plugin name]=>[blacklisting reason]
  7. * or an empty object if none of the dependencies to check are blacklisted.
  8. *
  9. * @param pkg - package.json contents
  10. * @param blacklist - contents of the blacklist in JSON format
  11. */
  12. function verifyDependencies(pkg, blacklist) {
  13. var blacklisted = matchdep
  14. .filterAll(Object.keys(blacklist), pkg)
  15. .reduce(function(blacklisted, pluginName) {
  16. blacklisted[pluginName] = blacklist[pluginName];
  17. return blacklisted;
  18. }, {});
  19. return blacklisted;
  20. }
  21. module.exports = verifyDependencies;