Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ function runCmd_ (cmd, pkg, env, wd, opts, stage, unsafe, uid, gid, cb_) {
proc.on('close', (code, signal) => {
opts.log.silly('lifecycle', logid(pkg, stage), 'Returned: code:', code, ' signal:', signal)
let err
if (signal && signal !== 'SIGINT') {
if (signal) {
err = new PnpmError('CHILD_PROCESS_FAILED', `Command failed with signal "${signal}"`)
process.kill(process.pid, signal)
} else if (code) {
Expand Down
9 changes: 5 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ test('throw error signal kills child', async function (t) {
stubProcessExit.restore()
})

test('no error on INT signal from child', async function (t) {
test('exit with error on INT signal from child', async function (t) {
if (isWindows()) {
// On Windows there is no way to get the INT signal
return
Expand Down Expand Up @@ -233,7 +233,7 @@ test('no error on INT signal from child', async function (t) {
const dir = fixture
const pkg = require(path.join(fixture, 'package.json'))

await t.resolves(async () => {
await t.rejects(async () => {
await lifecycle(pkg, 'signal-int', fixture, {
stdio: 'pipe',
log,
Expand All @@ -243,14 +243,15 @@ test('no error on INT signal from child', async function (t) {
})

stubProcessExit.restore()
stubProcessExit.calledOnceWith(process.pid, 'SIGINT')

t.ok(
!info.calledWithMatch(
info.calledWithMatch(
'lifecycle',
'undefined~signal-int:',
'Failed to exec signal-int script'
),
'INT signal intercepted incorrectly'
'INT signal not intercepted'
)

t.ok(
Expand Down
Loading