* docs: fix stale usage examples in six package READMEs The usage examples imported default exports these packages no longer have. They now import the named exports, call the current function names, and pass the options the current signatures accept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: import path in the lifecycle example, drop @pnpm/logger from the changeset @pnpm/logger is in versioning.ignore, so a changeset entry for it fails pnpm change check. The lifecycle example used path without importing it and require in an ES module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: single backslashes in the store path output, plain changeset wording Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1.1 KiB
1.1 KiB
@pnpm/exec.lifecycle
Package lifecycle hook runner
Installation
pnpm add @pnpm/logger @pnpm/exec.lifecycle
Usage
import { readFile } from 'node:fs/promises'
import path from 'node:path'
import { runLifecycleHook, runPostinstallHooks } from '@pnpm/exec.lifecycle'
const targetPkgRoot = path.resolve('node_modules/target-pkg')
const pkg = JSON.parse(await readFile(path.join(targetPkgRoot, 'package.json'), 'utf8'))
// Run a specific hook
await runLifecycleHook('preinstall', pkg, {
depPath: 'target-pkg@1.0.0',
pkgRoot: targetPkgRoot,
rootModulesDir: path.resolve('node_modules'),
unsafePerm: true,
})
// Run all install hooks
await runPostinstallHooks({
depPath: 'target-pkg@1.0.0',
pkgRoot: targetPkgRoot,
rootModulesDir: path.resolve('node_modules'),
unsafePerm: true,
})
API
runLifecycleHook(stage, packageManifest, opts): Promise<boolean>
runPostinstallHooks(opts): Promise<boolean>
License
MIT