@pnpm/lifecycle
Package lifecycle hook runner
Installation
<pnpm|npm|yarn> 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'))
await runLifecycleHook('preinstall', pkg, {
pkgId: 'target-pkg/1.0.0',
pkgRoot: targetPkgRoot,
rawNpmConfig: {},
rootNodeModulesDir: path.resolve('node_modules'),
unsafePerm: true,
})
await runPostinstallHooks({
pkgId: 'target-pkg/1.0.0',
pkgRoot: targetPkgRoot,
rawNpmConfig: {},
rootNodeModulesDir: path.resolve('node_modules'),
unsafePerm: true,
})
API
runLifecycleHook(stage, packageJson, opts): Promise<void>
runPostinstallHooks(opts): Promise<void>
License
MIT © Zoltan Kochan