Import the lifecycle runner from pnpm/npm-lifecycle at 178f3d5 as @pnpm/exec.npm-lifecycle, so it is maintained alongside its consumer and a fix no longer needs a separate release. The source is converted to TypeScript with typed options, package data, log and child-process interfaces, which replaces the any-typed declaration in __typings__/local.d.ts. The legacy pkg._data unwrapping and the unused opts.config are dropped. The tests are ported to jest. The node-gyp wrappers ship with the package; the runner finds them beside lib in the package and in dist once the CLI bundle has flattened the module, where the CLI ships its own copy. The manifest updater keeps node-gyp-bin in the package's files. @yarnpkg/shell's declarations import micromatch's, so a packageExtensions entry gives it @types/micromatch. The Artistic-2.0 license is preserved. The imported code includes the fix for the terminal SIGINT being relayed to a script that already had it (pnpm/npm-lifecycle#62), which this brings to pnpm v11; a pseudo-terminal test covers it in the package and in the CLI. Related to pnpm/pnpm#7374
32 lines
847 B
TypeScript
32 lines
847 B
TypeScript
import { expect, jest, test } from '@jest/globals'
|
|
|
|
import { spawn } from '../src/spawn.js'
|
|
|
|
test('progress is enabled again after a child that could not be spawned', async () => {
|
|
const log = {
|
|
progressEnabled: true,
|
|
disableProgress: jest.fn(),
|
|
enableProgress: jest.fn(),
|
|
}
|
|
|
|
const missing = spawn('this-command-does-not-exist', [], { stdio: 'inherit', log })
|
|
await new Promise<void>((resolve) => {
|
|
missing.once('error', () => {
|
|
resolve()
|
|
})
|
|
})
|
|
await new Promise<void>((resolve) => {
|
|
setImmediate(resolve)
|
|
})
|
|
|
|
const existing = spawn(process.execPath, ['-e', ''], { stdio: 'inherit', log })
|
|
await new Promise<void>((resolve) => {
|
|
existing.once('close', () => {
|
|
resolve()
|
|
})
|
|
})
|
|
|
|
expect(log.disableProgress).toHaveBeenCalled()
|
|
expect(log.enableProgress).toHaveBeenCalledTimes(2)
|
|
})
|