mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-28 03:51:40 -04:00
* fix: stop setting npm_config_ env vars from pnpm config during lifecycle scripts Update @pnpm/npm-lifecycle to 1100.0.0-0 which no longer dumps the entire pnpm config as npm_config_* environment variables. This fixes npm warnings about unknown config when lifecycle scripts invoke npm. Only well-known npm_* env vars are now set, matching Yarn's behavior. * fix: fix spellcheck in changeset * chore: remove obsolete @pnpm/npm-lifecycle patch file * fix: pass npm_config_user_agent via extraEnv in lifecycle scripts The npm-lifecycle makeEnv() strips all npm_* vars from process.env, so npm_config_user_agent must be explicitly passed via extraEnv. * chore: mark changeset as major (breaking change)
@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