mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-19 14:20:36 -04:00
PR #1573 * feat(reporting): collapse build output of deps inside node_modules ref #1440 * feat(reporting): nicer reporting of lifecycle output * feat(reporting): print the number of collapsed lines * feat(reporting): always print the status of the child processes * refactor: reporting * feat(reporting): nicer indentation * feat(reporting): report duration of script run close #1440
@pnpm/lifecycle
Package lifecycle hook runner
Installation
npm i -S @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,
rawNpmConfig: {},
rootNodeModulesDir: path.resolve('node_modules'),
unsafePerm: true,
})
// Run all install hooks
await runPostinstallHooks({
pkgId: 'target-pkg/1.0.0',
pkgRoot: targetPkgRoot,
rawNpmConfig: {},
rootNodeModulesDir: path.resolve('node_modules'),
unsafePerm: true,
})