pnpm/exec/lifecycle
Zoltan Kochan bcbcc47530
chore(release): 7.24.0
2023-01-09 19:25:36 +02:00
..
src fix: don't relink injected packages if they were not built (#5792) 2022-12-13 21:47:37 +02:00
test fix: throw an error while missing script start or server.js (#5782) 2022-12-12 10:47:14 +00:00
CHANGELOG.md chore(release): 7.24.0 2023-01-09 19:25:36 +02:00
README.md refactor: group projects in different subdirectories (#5659) 2022-11-20 01:35:22 +02:00
jest.config.js refactor: group projects in different subdirectories (#5659) 2022-11-20 01:35:22 +02:00
package.json chore(release): 7.24.0 2023-01-09 19:25:36 +02:00
tsconfig.json fix: throw an error while missing script start or server.js (#5782) 2022-12-12 10:47:14 +00:00
tsconfig.lint.json refactor: put all non-public projects to directories that start with __ 2022-11-20 02:40:44 +02:00

README.md

@pnpm/lifecycle

Package lifecycle hook runner

npm version

Installation

pnpm add @pnpm/logger @pnpm/lifecycle

Usage

import runLifecycleHook, {runPostinstallHooks} from '@pnpm/lifecycle'

const targetPkgRoot = path.resolve('node_modules/target-pkg')
const pkg = require(path.join(targetPkgRoot, 'package.json'))

// Run a specific hook
await runLifecycleHook('preinstall', pkg, {
  pkgId: 'target-pkg/1.0.0',
  pkgRoot: targetPkgRoot,
  rawConfig: {},
  rootModulesDir: path.resolve('node_modules'),
  unsafePerm: true,
})

// Run all install hooks
await runPostinstallHooks({
  pkgId: 'target-pkg/1.0.0',
  pkgRoot: targetPkgRoot,
  rawConfig: {},
  rootModulesDir: path.resolve('node_modules'),
  unsafePerm: true,
})

API

runLifecycleHook(stage, packageManifest, opts): Promise<void>

runPostinstallHooks(opts): Promise<void>

License

MIT