How to use the @pkgr/utils.monorepoPkgs.reduce function in @pkgr/utils

To help you get started, we’ve selected a few @pkgr/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 1stG / configs / packages / eslint-config / _util.js View on Github external
const { resolve } = require('path')

const {
  isMonorepo,
  isPkgAvailable,
  monorepoPkgs,
  tryRequirePkg,
} = require('@pkgr/utils')

if (isMonorepo) {
  exports.allowModules = monorepoPkgs.reduce((acc, pkg) => {
    const pkgJson = tryRequirePkg(resolve(pkg, 'package.json'))
    if (!pkgJson) {
      return acc
    }
    const { name, peerDependencies = {}, dependencies = {} } = pkgJson
    return acc.concat(
      name,
      Object.keys(peerDependencies),
      Object.keys(dependencies),
    )
  }, [])
}

exports.isWebpackAvailable = isPkgAvailable('webpack')

// https://webpack.js.org/api/module-variables/#__resourcequery-webpack-specific

@pkgr/utils

Shared utils for `@pkgr` packages or any package else

MIT
Latest version published 9 months ago

Package Health Score

74 / 100
Full package analysis

Similar packages