How to use the @pnpm/lockfile-utils.packageIsIndependent function in @pnpm/lockfile-utils

To help you get started, we’ve selected a few @pnpm/lockfile-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 pnpm / pnpm / packages / hoist / src / index.ts View on Github external
step: LockfileWalkerStep,
  depth: number,
  opts: {
    getIndependentPackageLocation?: (packageId: string, packageName: string) => Promise,
    registries: Registries,
    lockfileDir: string,
    virtualStoreDir: string,
  },
): Promise {
  const deps: Dependency[] = []
  const nextSteps: LockfileWalkerStep[] = []
  for (const { pkgSnapshot, relDepPath, next } of step.dependencies) {
    const absolutePath = dp.resolve(opts.registries, relDepPath)
    const pkgName = nameVerFromPkgSnapshot(relDepPath, pkgSnapshot).name
    const modules = path.join(opts.virtualStoreDir, pkgIdToFilename(absolutePath, opts.lockfileDir), 'node_modules')
    const independent = opts.getIndependentPackageLocation && packageIsIndependent(pkgSnapshot)
    const allDeps = {
      ...pkgSnapshot.dependencies,
      ...pkgSnapshot.optionalDependencies,
    }
    deps.push({
      absolutePath,
      children: Object.keys(allDeps).reduce((children, alias) => {
        children[alias] = dp.refToAbsolute(allDeps[alias], alias, opts.registries)
        return children
      }, {}),
      depth,
      location: !independent
        ? path.join(modules, pkgName)
        : await opts.getIndependentPackageLocation!(pkgSnapshot.id || absolutePath, pkgName),
      name: pkgName,
    })
github pnpm / pnpm / packages / plugin-commands-rebuild / src / implementation / index.ts View on Github external
      .filter((relDepPath) => !packageIsIndependent(pkgSnapshots[relDepPath]))
      .map((relDepPath) => limitLinking(() => {
github pnpm / pnpm / packages / plugin-commands-rebuild / src / implementation / index.ts View on Github external
async () => {
      const pkgSnapshot = pkgSnapshots[relDepPath]
      const depPath = dp.resolve(opts.registries, relDepPath)
      const pkgInfo = nameVerFromPkgSnapshot(relDepPath, pkgSnapshot)
      const independent = ctx.independentLeaves && packageIsIndependent(pkgSnapshot)
      const pkgRoot = !independent
        ? path.join(ctx.virtualStoreDir, pkgIdToFilename(depPath, opts.lockfileDir), 'node_modules', pkgInfo.name)
        : await (
          async () => {
            const { dir } = await opts.storeController.getPackageLocation(pkgSnapshot.id || depPath, pkgInfo.name, {
              lockfileDir: opts.lockfileDir,
              targetEngine: opts.sideEffectsCacheRead && !opts.force && ENGINE_NAME || undefined,
            })
            return dir
          }
        )()
      try {
        if (!independent) {
          const modules = path.join(ctx.virtualStoreDir, pkgIdToFilename(depPath, opts.lockfileDir), 'node_modules')
          const binPath = path.join(pkgRoot, 'node_modules', '.bin')
          await linkBins(modules, binPath, { warn })