mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-02 20:18:15 -05:00
* chore(scripts): typecheck-only * feat: change all configuration * feat: include pnpm/ and pnpm/test/ * chore(deps): remove unused dependency * refactor(typescript-only): use find-packages * refactor(typescript-only): refactor paths * fix: typescript-only * fix: update compile-only * fix: compile pnpm * fix: windows * fix: windows * chore: meta-updater * refactor(tsconfig): remove explicit composite * fix: path in windows * feat: don't depend on cwd --------- Co-authored-by: Zoltan Kochan <z@kochan.io>
@pnpm/lifecycle
Package lifecycle hook runner
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