How to use @pnpm/modules-cleaner - 4 common examples

To help you get started, we’ve selected a few @pnpm/modules-cleaner 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 / supi / src / link / index.ts View on Github external
addLinkToLockfile(ctx.currentLockfile.importers[importerId], addLinkOpts)
    addLinkToLockfile(ctx.wantedLockfile.importers[importerId], addLinkOpts)

    linkedPkgs.push({
      alias: linkFromAlias || manifest.name,
      manifest,
      path: linkFromPath,
    })
  }

  const updatedCurrentLockfile = pruneSharedLockfile(ctx.currentLockfile)

  const warn = (message: string) => logger.warn({ message, prefix: opts.dir })
  const updatedWantedLockfile = pruneSharedLockfile(ctx.wantedLockfile, { warn })

  await prune(
    [
      {
        binsDir: opts.binsDir,
        id: importerId,
        modulesDir: ctx.modulesDir,
        rootDir: opts.dir,
      },
    ],
    {
      currentLockfile,
      hoistedAliases: ctx.hoistedAliases,
      hoistedModulesDir: opts.hoistPattern && ctx.hoistedModulesDir || undefined,
      include: ctx.include,
      lockfileDir: opts.lockfileDir,
      registries: ctx.registries,
      skipped: ctx.skipped,
github pnpm / pnpm / packages / supi / src / uninstall / index.ts View on Github external
export async function uninstallInContext (
  pkgsToUninstall: string[],
  ctx: PnpmSingleContext,
  opts: StrictUninstallOptions,
) {
  const makePartialCurrentLockfile = !lockfilesEqual(ctx.currentLockfile, ctx.wantedLockfile)

  const saveType = getSaveType(opts)
  const pkg = await removeDeps(ctx.manifest, pkgsToUninstall, { prefix: opts.prefix, saveType })
  const newLockfile = pruneLockfile(ctx.wantedLockfile, pkg, ctx.importerId, {
    defaultRegistry: ctx.registries.default,
    warn: (message) => logger.warn({ message, prefix: ctx.prefix }),
  })
  const removedPkgIds = await prune({
    importers: [
      {
        bin: opts.bin,
        hoistedAliases: ctx.hoistedAliases,
        id: ctx.importerId,
        modulesDir: ctx.modulesDir,
        prefix: ctx.prefix,
        removePackages: pkgsToUninstall,
        shamefullyFlatten: opts.shamefullyFlatten,
      },
    ],
    lockfileDirectory: opts.lockfileDirectory,
    newLockfile,
    oldLockfile: ctx.currentLockfile,
    registries: ctx.registries,
    storeController: opts.storeController,
github pnpm / pnpm / packages / supi / src / uninstall / index.ts View on Github external
export async function uninstallInContext (
  pkgsToUninstall: string[],
  ctx: PnpmSingleContext,
  opts: StrictUninstallOptions,
) {
  const makePartialCurrentShrinkwrap = !shrinkwrapsEqual(ctx.currentShrinkwrap, ctx.wantedShrinkwrap)

  const pkgJsonPath = path.join(ctx.prefix, 'package.json')
  const saveType = getSaveType(opts)
  const pkg = await removeDeps(pkgJsonPath, pkgsToUninstall, { prefix: opts.prefix, saveType })
  const newShr = pruneShrinkwrap(ctx.wantedShrinkwrap, pkg, ctx.importerId, {
    defaultRegistry: ctx.registries.default,
    warn: (message) => logger.warn({ message, prefix: ctx.prefix }),
  })
  const removedPkgIds = await prune({
    importers: [
      {
        bin: opts.bin,
        hoistedAliases: ctx.hoistedAliases,
        id: ctx.importerId,
        modulesDir: ctx.modulesDir,
        prefix: ctx.prefix,
        shamefullyFlatten: opts.shamefullyFlatten,
      },
    ],
    newShrinkwrap: newShr,
    oldShrinkwrap: ctx.currentShrinkwrap,
    registries: ctx.registries,
    removePackages: pkgsToUninstall,
    shrinkwrapDirectory: opts.shrinkwrapDirectory,
    storeController: opts.storeController,
github pnpm / pnpm / packages / supi / src / install / link.ts View on Github external
opts.skipped.add(relDepPath)
      return false
    }
    opts.skipped.delete(relDepPath)
    return true
  })
  if (!opts.include.dependencies) {
    depNodes = depNodes.filter(({ dev, optional }) => dev !== false || optional)
  }
  if (!opts.include.devDependencies) {
    depNodes = depNodes.filter(({ dev }) => dev !== true)
  }
  if (!opts.include.optionalDependencies) {
    depNodes = depNodes.filter(({ optional }) => !optional)
  }
  const removedDepPaths = await prune(importers, {
    currentLockfile: opts.currentLockfile,
    dryRun: opts.dryRun,
    hoistedAliases: opts.hoistedAliases,
    hoistedModulesDir: opts.hoistPattern && opts.hoistedModulesDir || undefined,
    include: opts.include,
    lockfileDir: opts.lockfileDir,
    pruneStore: opts.pruneStore,
    registries: opts.registries,
    skipped: opts.skipped,
    storeController: opts.storeController,
    virtualStoreDir: opts.virtualStoreDir,
    wantedLockfile: newWantedLockfile,
  })

  stageLogger.debug({
    prefix: opts.lockfileDir,

@pnpm/modules-cleaner

Exports util functions to clean up node_modules

MIT
Latest version published 20 days ago

Package Health Score

63 / 100
Full package analysis

Popular @pnpm/modules-cleaner functions