"use strict";

var NODEJS_SYSTEM_PACKAGES = ["path", "os", "fs", "util", "events", "crypto"];

var extractDepsFromPackageJson = function extractDepsFromPackageJson(_ref) {
  var _ref$dependencies = _ref.dependencies,
      dependencies = _ref$dependencies === void 0 ? {} : _ref$dependencies,
      _ref$devDependencies = _ref.devDependencies,
      devDependencies = _ref$devDependencies === void 0 ? {} : _ref$devDependencies,
      _ref$peerDependencies = _ref.peerDependencies,
      peerDependencies = _ref$peerDependencies === void 0 ? {} : _ref$peerDependencies;
  return {
    dependencies: Object.keys(dependencies),
    devDependencies: Object.keys(devDependencies),
    peerDependencies: Object.keys(peerDependencies)
  };
};

var extractIgnoredDepsFromConfig = function extractIgnoredDepsFromConfig() {
  var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  var ignore = config.ignore || {};
  return {
    src: ignore.src || [],
    dependencies: ignore.dependencies || [],
    devDependencies: ignore.devDependencies || [],
    peerDependencies: ignore.peerDependencies || []
  };
};

var isIgnoredDep = function isIgnoredDep(_ref2) {
  var type = _ref2.type,
      dep = _ref2.dep,
      instance = _ref2.instance,
      adioRc = _ref2.adioRc;

  if (NODEJS_SYSTEM_PACKAGES.includes(dep)) {
    return true;
  }

  var ignored;

  if (adioRc) {
    ignored = extractIgnoredDepsFromConfig(adioRc);

    if (ignored[type]) {
      if (ignored[type] === true) {
        return true;
      }

      if (Array.isArray(ignored[type]) && ignored[type].includes(dep)) {
        return true;
      }
    }
  }

  ignored = extractIgnoredDepsFromConfig(instance.config);

  if (ignored[type]) {
    if (ignored[type] === true) {
      return true;
    }

    if (Array.isArray(ignored[type]) && ignored[type].includes(dep)) {
      return true;
    }
  }

  return false;
};

module.exports = {
  extractDepsFromPackageJson: extractDepsFromPackageJson,
  extractIgnoredDepsFromConfig: extractIgnoredDepsFromConfig,
  isIgnoredDep: isIgnoredDep
};
//# sourceMappingURL=testPackage.js.map