mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-07 15:38:24 -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
63 lines
1.8 KiB
TypeScript
63 lines
1.8 KiB
TypeScript
import test = require('tape')
|
|
import runLifecycleHook, {runPostinstallHooks} from '@pnpm/lifecycle'
|
|
import path = require('path')
|
|
import rimraf = require('rimraf')
|
|
import loadJsonFile = require('load-json-file')
|
|
|
|
const fixtures = path.join(__dirname, 'fixtures')
|
|
const rootNodeModulesDir = path.join(__dirname, '..', 'node_modules')
|
|
|
|
test('runLifecycleHook()', async (t) => {
|
|
const pkgRoot = path.join(fixtures, 'simple')
|
|
const pkg = require(path.join(pkgRoot, 'package.json'))
|
|
await runLifecycleHook('postinstall', pkg, {
|
|
depPath: '/simple/1.0.0',
|
|
optional: false,
|
|
pkgRoot,
|
|
rawNpmConfig: {},
|
|
rootNodeModulesDir,
|
|
unsafePerm: true,
|
|
})
|
|
|
|
t.deepEqual(require(path.join(pkgRoot, 'output.json')), ['install'])
|
|
|
|
t.end()
|
|
})
|
|
|
|
test('runPostinstallHooks()', async (t) => {
|
|
const pkgRoot = path.join(fixtures, 'with-many-scripts')
|
|
const pkg = require(path.join(pkgRoot, 'package.json'))
|
|
rimraf.sync(path.join(pkgRoot, 'output.json'))
|
|
await runPostinstallHooks({
|
|
depPath: '/with-many-scripts/1.0.0',
|
|
optional: false,
|
|
pkgRoot,
|
|
rawNpmConfig: {},
|
|
rootNodeModulesDir,
|
|
unsafePerm: true,
|
|
})
|
|
|
|
t.deepEqual(loadJsonFile.sync(path.join(pkgRoot, 'output.json')), ['preinstall', 'install', 'postinstall'])
|
|
|
|
t.end()
|
|
})
|
|
|
|
test('runPostinstallHooks() with prepare = true', async (t) => {
|
|
const pkgRoot = path.join(fixtures, 'with-many-scripts')
|
|
const pkg = require(path.join(pkgRoot, 'package.json'))
|
|
rimraf.sync(path.join(pkgRoot, 'output.json'))
|
|
await runPostinstallHooks({
|
|
depPath: '/with-many-scripts/1.0.0',
|
|
optional: false,
|
|
pkgRoot,
|
|
prepare: true,
|
|
rawNpmConfig: {},
|
|
rootNodeModulesDir,
|
|
unsafePerm: true,
|
|
})
|
|
|
|
t.deepEqual(loadJsonFile.sync(path.join(pkgRoot, 'output.json')), ['preinstall', 'install', 'postinstall', 'prepare'])
|
|
|
|
t.end()
|
|
})
|