Skip to content

Commit f3f2b38

Browse files
committed
v4 rewrite: hybrid module, TS, and named exports
1 parent d4adbeb commit f3f2b38

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+4216
-10534
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
build:
77
strategy:
88
matrix:
9-
node-version: [12.x, 14.x, 16.x, 17.x]
9+
node-version: [14.x, 16.x, 18.x, 19.x]
1010
platform:
1111
- os: ubuntu-latest
1212
shell: bash
@@ -25,10 +25,10 @@ jobs:
2525

2626
steps:
2727
- name: Checkout Repository
28-
uses: actions/checkout@v1.1.0
28+
uses: actions/checkout@v3
2929

3030
- name: Use Nodejs ${{ matrix.node-version }}
31-
uses: actions/setup-node@v1
31+
uses: actions/setup-node@v3
3232
with:
3333
node-version: ${{ matrix.node-version }}
3434

.github/workflows/typedoc.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: Deploy static content to Pages
3+
4+
on:
5+
# Runs on pushes targeting the default branch
6+
push:
7+
branches: ["main"]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow one concurrent deployment
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: true
22+
23+
jobs:
24+
# Single deploy job since we're just deploying
25+
deploy:
26+
environment:
27+
name: github-pages
28+
url: ${{ steps.deployment.outputs.page_url }}
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v3
33+
- name: Use Nodejs ${{ matrix.node-version }}
34+
uses: actions/setup-node@v3
35+
with:
36+
node-version: 18.x
37+
- name: Install dependencies
38+
run: npm install
39+
- name: Generate typedocs
40+
run: npm run typedoc
41+
- name: Setup Pages
42+
uses: actions/configure-pages@v3
43+
- name: Upload artifact
44+
uses: actions/upload-pages-artifact@v1
45+
with:
46+
path: './docs'
47+
- name: Deploy to GitHub Pages
48+
id: deployment
49+
uses: actions/deploy-pages@v1

CHANGELOG.md

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
11
# Changelog
22

3-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
3+
## 4.0
44

5-
### [3.0.3](https://github.com/tapjs/signal-exit/compare/v3.0.2...v3.0.3) (2020-03-26)
5+
- Rewritten in TypeScript
6+
- Default export replaced with named exports
7+
- More securely hardened against multiple load and global process
8+
object mutation
9+
- Removed `SIGUNUSED` from the list of Linux signals, as it no
10+
longer exists.
11+
- `SIGABRT`, `SIGALRM` removed from list of Windows signals, as
12+
the are not supported.
613

14+
## 3.0.3 (2020-03-26)
715

8-
### Bug Fixes
16+
- patch SIGHUP to SIGINT when on Windows (cfd1046)
17+
- ci: use Travis for Windows builds (007add7)
918

10-
* patch `SIGHUP` to `SIGINT` when on Windows ([cfd1046](https://github.com/tapjs/signal-exit/commit/cfd1046079af4f0e44f93c69c237a09de8c23ef2))
11-
* **ci:** use Travis for Windows builds ([007add7](https://github.com/tapjs/signal-exit/commit/007add793d2b5ae3c382512103adbf321768a0b8))
19+
## 3.0.1 (2016-09-08)
1220

13-
<a name="3.0.1"></a>
14-
## [3.0.1](https://github.com/tapjs/signal-exit/compare/v3.0.0...v3.0.1) (2016-09-08)
21+
- do not listen on SIGBUS, SIGFPE, SIGSEGV and SIGILL (#40) (5b105fb)
1522

23+
## 3.0.0 (2016-06-13)
1624

17-
### Bug Fixes
18-
19-
* do not listen on SIGBUS, SIGFPE, SIGSEGV and SIGILL ([#40](https://github.com/tapjs/signal-exit/issues/40)) ([5b105fb](https://github.com/tapjs/signal-exit/commit/5b105fb))
20-
21-
22-
23-
<a name="3.0.0"></a>
24-
# [3.0.0](https://github.com/tapjs/signal-exit/compare/v2.1.2...v3.0.0) (2016-06-13)
25-
26-
27-
### Bug Fixes
28-
29-
* get our test suite running on Windows ([#23](https://github.com/tapjs/signal-exit/issues/23)) ([6f3eda8](https://github.com/tapjs/signal-exit/commit/6f3eda8))
30-
* hooking SIGPROF was interfering with profilers see [#21](https://github.com/tapjs/signal-exit/issues/21) ([#24](https://github.com/tapjs/signal-exit/issues/24)) ([1248a4c](https://github.com/tapjs/signal-exit/commit/1248a4c))
31-
32-
33-
### BREAKING CHANGES
34-
35-
* signal-exit no longer wires into SIGPROF
25+
- get our test suite running on Windows (#23) (6f3eda8)
26+
- hooking SIGPROF was interfering with profilers see #21 (#24) (1248a4c)
27+
- signal-exit no longer wires into SIGPROF

README.md

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,51 @@
11
# signal-exit
22

3-
[![Build Status](https://travis-ci.org/tapjs/signal-exit.png)](https://travis-ci.org/tapjs/signal-exit)
4-
[![Coverage](https://coveralls.io/repos/tapjs/signal-exit/badge.svg?branch=master)](https://coveralls.io/r/tapjs/signal-exit?branch=master)
5-
[![NPM version](https://img.shields.io/npm/v/signal-exit.svg)](https://www.npmjs.com/package/signal-exit)
6-
[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version)
7-
83
When you want to fire an event no matter how a process exits:
94

10-
* reaching the end of execution.
11-
* explicitly having `process.exit(code)` called.
12-
* having `process.kill(pid, sig)` called.
13-
* receiving a fatal signal from outside the process
5+
- reaching the end of execution.
6+
- explicitly having `process.exit(code)` called.
7+
- having `process.kill(pid, sig)` called.
8+
- receiving a fatal signal from outside the process
149

1510
Use `signal-exit`.
1611

1712
```js
18-
var onExit = require('signal-exit')
13+
// Hybrid module, either works
14+
import { onExit } from 'signal-exit'
15+
// or:
16+
// const { onExit } = require('signal-exit')
1917

20-
onExit(function (code, signal) {
21-
console.log('process exited!')
18+
onExit((code, signal) => {
19+
console.log('process exited!', code, signal)
2220
})
2321
```
2422

2523
## API
2624

27-
`var remove = onExit(function (code, signal) {}, options)`
25+
`remove = onExit((code, signal) => {}, options)`
26+
27+
The return value of the function is a function that will remove
28+
the handler.
29+
30+
Note that the function _only_ fires for signals if the signal
31+
would cause the process to exit. That is, there are no other
32+
listeners, and it is a fatal signal.
33+
34+
If the global `process` object is not suitable for this purpose
35+
(ie, it's unset, or doesn't have an `emit` method, etc.) then the
36+
`onExit` function is a no-op that returns a no-op `remove` method.
37+
38+
### Options
2839

29-
The return value of the function is a function that will remove the
30-
handler.
40+
- `alwaysLast`: Run this handler after any other signal or exit
41+
handlers. This causes `process.emit` to be monkeypatched.
3142

32-
Note that the function *only* fires for signals if the signal would
33-
cause the process to exit. That is, there are no other listeners, and
34-
it is a fatal signal.
43+
### Browser Fallback
3544

36-
## Options
45+
The `'signal-exit/browser'` module is the same fallback shim that
46+
just doesn't do anything, but presents the same function
47+
interface.
3748

38-
* `alwaysLast`: Run this handler after any other signal or exit
39-
handlers. This causes `process.emit` to be monkeypatched.
49+
Patches welcome to add something that hooks onto
50+
`window.onbeforeunload` or similar, but it might just not be a
51+
thing that makes sense there.

0 commit comments

Comments
 (0)