-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from theogravity/update-hook-retry
fix(datadog-transport-common): update p-retry to 6.2.0, exit-hook to 4.0.0
- Loading branch information
Showing
45 changed files
with
1,798 additions
and
52 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx --no-install commitlint --edit "$1" |
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,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
pnpm i |
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 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
pnpm typecheck | ||
pnpm lint:packages | ||
pnpm test | ||
pnpm lint-staged |
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
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,28 @@ | ||
module.exports = { | ||
extends: ['@commitlint/config-conventional'], | ||
rules: { | ||
'scope-enum': [2, 'always', | ||
[ | ||
'all', | ||
'datadog-transport-common', | ||
'electron-log-transport-datadog', | ||
'pino-datadog-transport' | ||
]], | ||
'type-enum': [ | ||
2, | ||
'always', | ||
[ | ||
'feat', | ||
'fix', | ||
'docs', | ||
'chore', | ||
'style', | ||
'refactor', | ||
'ci', | ||
'test', | ||
'revert', | ||
'perf' | ||
], | ||
], | ||
}, | ||
}; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
We're using a copy of | ||
|
||
- [`exit-hook`](https://github.com/sindresorhus/exit-hook) | ||
- [`p-retry'](https://github.com/sindresorhus/p-retry) | ||
|
||
instead of using the package directly because newer versions are ESM-only | ||
and this project supports both ESM and CJS. |
12 changes: 12 additions & 0 deletions
12
packages/datadog-transport-common/src/vendor/exit-hook/.editorconfig
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,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.yml] | ||
indent_style = space | ||
indent_size = 2 |
1 change: 1 addition & 0 deletions
1
packages/datadog-transport-common/src/vendor/exit-hook/.gitattributes
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 @@ | ||
* text=auto eol=lf |
4 changes: 4 additions & 0 deletions
4
packages/datadog-transport-common/src/vendor/exit-hook/.github/funding.yml
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,4 @@ | ||
github: sindresorhus | ||
open_collective: sindresorhus | ||
tidelift: npm/exit-hook | ||
custom: https://sindresorhus.com/donate |
3 changes: 3 additions & 0 deletions
3
packages/datadog-transport-common/src/vendor/exit-hook/.github/security.md
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,3 @@ | ||
# Security Policy | ||
|
||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. |
21 changes: 21 additions & 0 deletions
21
packages/datadog-transport-common/src/vendor/exit-hook/.github/workflows/main.yml
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,21 @@ | ||
name: CI | ||
on: | ||
- push | ||
- pull_request | ||
jobs: | ||
test: | ||
name: Node.js ${{ matrix.node-version }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: | ||
- 20 | ||
- 18 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
- run: npm test |
2 changes: 2 additions & 0 deletions
2
packages/datadog-transport-common/src/vendor/exit-hook/.gitignore
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,2 @@ | ||
node_modules | ||
yarn.lock |
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 @@ | ||
package-lock=false |
37 changes: 37 additions & 0 deletions
37
packages/datadog-transport-common/src/vendor/exit-hook/fixtures/async.js
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 @@ | ||
import process from 'node:process'; | ||
import exitHook, {asyncExitHook, gracefulExit} from '../index.js'; | ||
|
||
exitHook(() => { | ||
console.log('foo'); | ||
}); | ||
|
||
exitHook(() => { | ||
console.log('bar'); | ||
}); | ||
|
||
const unsubscribe = exitHook(() => { | ||
console.log('baz'); | ||
}); | ||
|
||
unsubscribe(); | ||
|
||
asyncExitHook( | ||
async () => { | ||
await new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, 100); | ||
}); | ||
|
||
console.log('quux'); | ||
}, | ||
{ | ||
wait: 200, | ||
}, | ||
); | ||
|
||
if (process.env.EXIT_HOOK_SYNC === '1') { | ||
process.exit(0); // eslint-disable-line unicorn/no-process-exit | ||
} | ||
|
||
gracefulExit(); |
5 changes: 5 additions & 0 deletions
5
packages/datadog-transport-common/src/vendor/exit-hook/fixtures/empty.js
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,5 @@ | ||
import exitHook from '../index.js'; | ||
|
||
exitHook(() => { | ||
// https://github.com/sindresorhus/exit-hook/issues/23 | ||
}); |
13 changes: 13 additions & 0 deletions
13
packages/datadog-transport-common/src/vendor/exit-hook/fixtures/signal.js
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,13 @@ | ||
import exitHook, {asyncExitHook} from '../index.js'; | ||
|
||
exitHook(signal => { | ||
console.log(signal); | ||
}); | ||
|
||
asyncExitHook(async signal => { | ||
console.log(signal); | ||
}, { | ||
wait: 200, | ||
}); | ||
|
||
setInterval(() => {}, 1e9); |
18 changes: 18 additions & 0 deletions
18
packages/datadog-transport-common/src/vendor/exit-hook/fixtures/sync.js
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,18 @@ | ||
import process from 'node:process'; | ||
import exitHook from '../index.js'; | ||
|
||
exitHook(() => { | ||
console.log('foo'); | ||
}); | ||
|
||
exitHook(() => { | ||
console.log('bar'); | ||
}); | ||
|
||
const unsubscribe = exitHook(() => { | ||
console.log('baz'); | ||
}); | ||
|
||
unsubscribe(); | ||
|
||
process.exit(0); // eslint-disable-line unicorn/no-process-exit |
100 changes: 100 additions & 0 deletions
100
packages/datadog-transport-common/src/vendor/exit-hook/index.d.ts
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,100 @@ | ||
/** | ||
@callback onExit | ||
@param {number} signal - The exit code. | ||
*/ | ||
|
||
/** | ||
Run some code when the process exits. | ||
The `process.on('exit')` event doesn't catch all the ways a process can exit. | ||
This is useful for cleaning synchronously before exiting. | ||
@param {onExit} onExit - The callback function to execute when the process exits. | ||
@returns A function that removes the hook when called. | ||
@example | ||
``` | ||
import exitHook from 'exit-hook'; | ||
exitHook(signal => { | ||
console.log(`Exiting with signal: ${signal}`); | ||
}); | ||
// 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(); | ||
``` | ||
*/ | ||
export default function exitHook(onExit: (signal: number) => void): () => void; | ||
|
||
/** | ||
Run code asynchronously when the process exits. | ||
@see https://github.com/sindresorhus/exit-hook/blob/main/readme.md#asynchronous-exit-notes | ||
@param {onExit} onExit - The callback function to execute when the process exits via `gracefulExit`, and will be wrapped in `Promise.resolve`. | ||
@returns A function that removes the hook when called. | ||
@example | ||
``` | ||
import {asyncExitHook} from 'exit-hook'; | ||
asyncExitHook(() => { | ||
console.log('Exiting'); | ||
}, { | ||
wait: 500 | ||
}); | ||
throw new Error('🦄'); | ||
//=> 'Exiting' | ||
// Removing an exit hook: | ||
const unsubscribe = asyncExitHook(() => {}, {wait: 500}); | ||
unsubscribe(); | ||
``` | ||
*/ | ||
export function asyncExitHook(onExit: (signal: number) => (void | Promise<void>), options: Options): () => void; | ||
|
||
/** | ||
Exit the process and make a best-effort to complete all asynchronous hooks. | ||
If you are using `asyncExitHook`, consider using `gracefulExit()` instead of `process.exit()` to ensure all asynchronous tasks are given an opportunity to run. | ||
@param signal - The exit code to use. Same as the argument to `process.exit()`. | ||
@see https://github.com/sindresorhus/exit-hook/blob/main/readme.md#asynchronous-exit-notes | ||
@example | ||
``` | ||
import {asyncExitHook, gracefulExit} from 'exit-hook'; | ||
asyncExitHook(() => { | ||
console.log('Exiting'); | ||
}, { | ||
wait: 500 | ||
}); | ||
// Instead of `process.exit()` | ||
gracefulExit(); | ||
``` | ||
*/ | ||
export function gracefulExit(signal?: number): void; | ||
|
||
export type Options = { | ||
/** | ||
The amount of time in milliseconds that the `onExit` function is expected to take. When multiple async handlers are registered, the longest `wait` time will be used. | ||
*/ | ||
readonly wait: number; | ||
}; |
Oops, something went wrong.