How to use the @pnpm/lifecycle.runLifecycleHooksConcurrently function in @pnpm/lifecycle

To help you get started, we’ve selected a few @pnpm/lifecycle 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 / install / index.ts View on Github external
const makePartialCurrentLockfile = !installsOnly && (
      ctx.existsWantedLockfile && !ctx.existsCurrentLockfile ||
      // TODO: this operation is quite expensive. We'll have to find a better solution to do this.
      // maybe in pnpm v2 it won't be needed. See: https://github.com/pnpm/pnpm/issues/841
      !equalLockfiles
    )
    const result = await installInContext(importersToInstall, ctx, {
      ...opts,
      currentLockfileIsUpToDate,
      makePartialCurrentLockfile,
      update: opts.update || !installsOnly,
      updateLockfileMinorVersion: true,
    })

    if (!opts.ignoreScripts) {
      await runLifecycleHooksConcurrently(['install', 'postinstall', 'prepublish', 'prepare'],
        importersToBeInstalled,
        opts.childConcurrency,
        scriptsOpts,
      )
    }

    return result
  }
}
github pnpm / pnpm / packages / supi / src / install / index.ts View on Github external
})
        return importers
      }
    }

    const importersToInstall = [] as ImporterToUpdate[]

    const importersToBeInstalled = ctx.importers.filter(({ mutation }) => mutation === 'install') as Array<{ buildIndex: number, rootDir: string, manifest: ImporterManifest, modulesDir: string }>
    const scriptsOpts = {
      extraBinPaths: opts.extraBinPaths,
      rawConfig: opts.rawConfig,
      stdio: opts.ownLifecycleHooksStdio,
      unsafePerm: opts.unsafePerm || false,
    }
    if (!opts.ignoreScripts) {
      await runLifecycleHooksConcurrently(
        ['preinstall'],
        importersToBeInstalled,
        opts.childConcurrency,
        scriptsOpts,
      )
    }

    // TODO: make it concurrent
    for (const importer of ctx.importers) {
      switch (importer.mutation) {
        case 'uninstallSome':
          importersToInstall.push({
            pruneDirectDependencies: false,
            ...importer,
            removePackages: importer.dependencyNames,
            updatePackageManifest: true,
github pnpm / pnpm / packages / plugin-commands-rebuild / src / implementation / index.ts View on Github external
const pkgsThatWereRebuilt = await _rebuild(
    {
      pkgsToRebuild: new Set(idsToRebuild),
      ...ctx,
    },
    opts,
  )

  ctx.pendingBuilds = ctx.pendingBuilds.filter((relDepPath) => !pkgsThatWereRebuilt.has(relDepPath))

  const scriptsOpts = {
    extraBinPaths: ctx.extraBinPaths,
    rawConfig: opts.rawConfig,
    unsafePerm: opts.unsafePerm || false,
  }
  await runLifecycleHooksConcurrently(
    ['preinstall', 'install', 'postinstall', 'prepublish', 'prepare'],
    ctx.importers,
    opts.childConcurrency || 5,
    scriptsOpts,
  )
  for (const { id, manifest } of ctx.importers) {
    if (manifest?.scripts && (!opts.pending || ctx.pendingBuilds.includes(id))) {
      ctx.pendingBuilds.splice(ctx.pendingBuilds.indexOf(id), 1)
    }
  }

  await writeModulesYaml(ctx.rootModulesDir, {
    ...ctx.modulesFile,
    hoistedAliases: ctx.hoistedAliases,
    hoistPattern: ctx.hoistPattern,
    included: ctx.include,

@pnpm/lifecycle

Package lifecycle hook runner

MIT
Latest version published 7 days ago

Package Health Score

57 / 100
Full package analysis