How to use the @pnpm/link-bins.linkBinsOfPackages function in @pnpm/link-bins

To help you get started, we’ve selected a few @pnpm/link-bins 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 / build-modules / src / index.ts View on Github external
// TODO: Try to reproduce this issue with a test in supi
          logger.debug({ message: `Failed to link bins of "${alias}" to "${binPath}". This is probably not an issue.` })
          return false
        }
        return dep.hasBin && dep.installable !== false
      })
      .map(async (alias) => {
        const dep = depGraph[childrenToLink[alias]]
        return {
          location: dep.peripheralLocation,
          manifest: await dep.fetchingBundledManifest?.() || (await readPackageFromDir(dep.peripheralLocation) as DependencyManifest),
        }
      }),
  )

  await linkBinsOfPackages(pkgs, binPath, { warn: opts.warn })

  // link also the bundled dependencies` bins
  if (depNode.hasBundledDependencies) {
    const bundledModules = path.join(depNode.peripheralLocation, 'node_modules')
    await linkBins(bundledModules, binPath, { warn: opts.warn })
  }
}
github pnpm / pnpm / packages / supi / src / link / index.ts View on Github external
)

  // Linking should happen after removing orphans
  // Otherwise would've been removed
  for (const { alias, manifest, path } of linkedPkgs) {
    // TODO: cover with test that linking reports with correct dependency types
    const stu = specsToUpsert.find((s) => s.alias === manifest.name)
    await symlinkDirectRootDependency(path, destModules, alias, {
      fromDependenciesField: stu?.saveType ?? opts.targetDependenciesField,
      linkedPackage: manifest,
      prefix: opts.dir,
    })
  }

  const linkToBin = maybeOpts?.linkToBin || path.join(destModules, '.bin')
  await linkBinsOfPackages(linkedPkgs.map((p) => ({ manifest: p.manifest, location: p.path })), linkToBin, {
    warn: (message: string) => logger.warn({ message, prefix: opts.dir }),
  })

  let newPkg!: ImporterManifest
  if (opts.targetDependenciesField) {
    newPkg = await save(opts.dir, opts.manifest, specsToUpsert)
    for (const { alias } of specsToUpsert) {
      updatedWantedLockfile.importers[importerId].specifiers[alias] = getSpecFromPackageManifest(newPkg, alias)
    }
  } else {
    newPkg = opts.manifest
  }
  const lockfileOpts = { forceSharedFormat: opts.forceSharedLockfile }
  if (opts.useLockfile) {
    await writeLockfiles({
      currentLockfile: updatedCurrentLockfile,

@pnpm/link-bins

Link bins to node_modules/.bin

MIT
Latest version published 7 days ago

Package Health Score

68 / 100
Full package analysis

Popular @pnpm/link-bins functions