Skip to content

Commit

Permalink
v4 rewrite: hybrid module, TS, and named exports
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Apr 15, 2023
1 parent d4adbeb commit f3f2b38
Show file tree
Hide file tree
Showing 48 changed files with 4,216 additions and 10,534 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 17.x]
node-version: [14.x, 16.x, 18.x, 19.x]
platform:
- os: ubuntu-latest
shell: bash
Expand All @@ -25,10 +25,10 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v1.1.0
uses: actions/checkout@v3

- name: Use Nodejs ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/typedoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Nodejs ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install dependencies
run: npm install
- name: Generate typedocs
run: npm run typedoc
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: './docs'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
44 changes: 18 additions & 26 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
# Changelog

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.
## 4.0

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

## 3.0.3 (2020-03-26)

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

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

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

## 3.0.0 (2016-06-13)

### Bug Fixes

* 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))



<a name="3.0.0"></a>
# [3.0.0](https://github.com/tapjs/signal-exit/compare/v2.1.2...v3.0.0) (2016-06-13)


### Bug Fixes

* 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))
* 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))


### BREAKING CHANGES

* signal-exit no longer wires into SIGPROF
- get our test suite running on Windows (#23) (6f3eda8)
- hooking SIGPROF was interfering with profilers see #21 (#24) (1248a4c)
- signal-exit no longer wires into SIGPROF
54 changes: 33 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,51 @@
# signal-exit

[![Build Status](https://travis-ci.org/tapjs/signal-exit.png)](https://travis-ci.org/tapjs/signal-exit)
[![Coverage](https://coveralls.io/repos/tapjs/signal-exit/badge.svg?branch=master)](https://coveralls.io/r/tapjs/signal-exit?branch=master)
[![NPM version](https://img.shields.io/npm/v/signal-exit.svg)](https://www.npmjs.com/package/signal-exit)
[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version)

When you want to fire an event no matter how a process exits:

* reaching the end of execution.
* explicitly having `process.exit(code)` called.
* having `process.kill(pid, sig)` called.
* receiving a fatal signal from outside the process
- reaching the end of execution.
- explicitly having `process.exit(code)` called.
- having `process.kill(pid, sig)` called.
- receiving a fatal signal from outside the process

Use `signal-exit`.

```js
var onExit = require('signal-exit')
// Hybrid module, either works
import { onExit } from 'signal-exit'
// or:
// const { onExit } = require('signal-exit')

onExit(function (code, signal) {
console.log('process exited!')
onExit((code, signal) => {
console.log('process exited!', code, signal)
})
```

## API

`var remove = onExit(function (code, signal) {}, options)`
`remove = onExit((code, signal) => {}, options)`

The return value of the function is a function that will remove
the handler.

Note that the function _only_ fires for signals if the signal
would cause the process to exit. That is, there are no other
listeners, and it is a fatal signal.

If the global `process` object is not suitable for this purpose
(ie, it's unset, or doesn't have an `emit` method, etc.) then the
`onExit` function is a no-op that returns a no-op `remove` method.

### Options

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

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

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

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

0 comments on commit f3f2b38

Please sign in to comment.