-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79c3bce
commit 09ebd60
Showing
6 changed files
with
66 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
* text=auto | ||
*.js text eol=lf | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
language: node_js | ||
node_js: | ||
- '10' | ||
- '8' | ||
- '6' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
Run some code when the process exits. | ||
The `process.on('exit')` event doesn't catch all the ways a process can exit. | ||
This package is useful for cleaning up before exiting. | ||
@param callback - The callback to execute when the process exits. | ||
@returns A function that removes the hook when called. | ||
@example | ||
``` | ||
import exitHook = require('exit-hook'); | ||
exitHook(() => { | ||
console.log('Exiting'); | ||
}); | ||
// You can add multiple hooks, even across files | ||
exitHook(() => { | ||
console.log('Exiting 2'); | ||
}); | ||
throw new Error('🦄'); | ||
//=> 'Exiting' | ||
//=> 'Exiting 2' | ||
// Removing an exit hook: | ||
const unsubscribe = exitHook(() => {}); | ||
unsubscribe(); | ||
``` | ||
*/ | ||
declare function exitHook(callback: () => void): () => void; | ||
|
||
export = exitHook; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {expectType} from 'tsd'; | ||
import exitHook = require('.'); | ||
|
||
const unsubscribe = exitHook(() => {}); | ||
|
||
expectType<() => void>(unsubscribe); | ||
unsubscribe(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters