Skip to content

Commit

Permalink
Remove p-event
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 7, 2023
1 parent 7e9ac0f commit b95d240
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"normalize-exception": "^2.11.0",
"nvexeca": "^8.5.0",
"os-name": "^5.1.0",
"p-event": "^5.0.1",
"p-locate": "^6.0.0",
"p-map": "^5.5.0",
"p-map-series": "^3.0.0",
Expand Down
11 changes: 6 additions & 5 deletions src/run/stop/handle.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { once } from 'node:events'
import process from 'node:process'

import delay from 'delay'
import { pEvent } from 'p-event'

import { addAction, removeAction } from '../preview/action.js'
import { updateDescription, STOP_DESCRIPTION } from '../preview/description.js'
Expand Down Expand Up @@ -40,11 +40,12 @@ const afterAbort = async (previewState) => {
throwAbortError()
}

// TODO: replace with `once()` after dropping support for Node <15
const waitForStopSignals = async ({ cancelSignal }) => {
const promise = pEvent(process, STOP_SIGNALS)
cancelSignal.addEventListener('abort', promise.cancel)
await promise
await Promise.any(
STOP_SIGNALS.map((stopSignal) =>
once(process, stopSignal, { signal: cancelSignal }),
),
)
}

// Users must wait 5 seconds before being able to abort.
Expand Down

0 comments on commit b95d240

Please sign in to comment.