@sequencemedia/process 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@sequencemedia/process",
3
+ "version": "0.0.0",
4
+ "description": "Node process handlers",
5
+ "keywords": [
6
+ "Node",
7
+ "process"
8
+ ],
9
+ "main": "./src/index.mjs",
10
+ "type": "module",
11
+ "author": {
12
+ "name": "Jonathan Perry for Sequence Media Limited",
13
+ "email": "sequencemedia@sequencemedia.net",
14
+ "url": "https://sequencemedia.net"
15
+ },
16
+ "license": "ISC",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+ssh://git@github.com/sequencemedia/process.git"
20
+ },
21
+ "homepage": "https://github.com/sequencemedia/process#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/sequencemedia/process/issues"
24
+ },
25
+ "scripts": {
26
+ "lint": "eslint .",
27
+ "lint:fix": "npm run lint -- --fix"
28
+ },
29
+ "dependencies": {
30
+ "debug": "^4.4.0"
31
+ },
32
+ "devDependencies": {
33
+ "@babel/core": "^7.26.0",
34
+ "@babel/preset-env": "^7.26.0",
35
+ "@sequencemedia/eslint-config-standard": "^0.2.13",
36
+ "core-js": "^3.40.0",
37
+ "eslint": "^9.18.0",
38
+ "globals": "^15.14.0"
39
+ },
40
+ "exports": {
41
+ ".": "./src/index.mjs",
42
+ "./common": "./src/common/index.mjs"
43
+ }
44
+ }
@@ -0,0 +1,76 @@
1
+ import debug from 'debug'
2
+ import process from 'node:process'
3
+
4
+ const log = debug('@sequencemedia/process')
5
+
6
+ export function handleSigHup (signal) {
7
+ log('sigHup', signal)
8
+
9
+ const {
10
+ stdout
11
+ } = process
12
+
13
+ if ('clearLine' in stdout) {
14
+ stdout.clearLine()
15
+ stdout.cursorTo(0)
16
+ }
17
+
18
+ process.exit(0)
19
+ }
20
+
21
+ export function handleSigInt (signal) {
22
+ log('sigInt', signal)
23
+
24
+ const {
25
+ stdout
26
+ } = process
27
+
28
+ if ('clearLine' in stdout) {
29
+ stdout.clearLine()
30
+ stdout.cursorTo(0)
31
+ }
32
+
33
+ process.exit(0)
34
+ }
35
+
36
+ export function handleSigBreak (signal) {
37
+ log('sigBreak', signal)
38
+
39
+ process.exit(0)
40
+ }
41
+
42
+ export function handleSigQuit (signal) {
43
+ log('sigQuit', signal)
44
+
45
+ process.exit(0)
46
+ }
47
+
48
+ export function handleSigTerm (signal) {
49
+ log('sigTerm', signal)
50
+
51
+ process.exit(0)
52
+ }
53
+
54
+ export function handleSigPipe (signal) {
55
+ log('sigPipe', signal)
56
+ }
57
+
58
+ export function handleBeforeExit (code) {
59
+ log('beforeExit', code)
60
+ }
61
+
62
+ export function handleExit (code) {
63
+ log('exit', code)
64
+ }
65
+
66
+ export function handleUncaughtException ({ message }) {
67
+ log('uncaughtException', message)
68
+
69
+ process.exit(1)
70
+ }
71
+
72
+ export function handleUnhandledRejection (reason, promise) {
73
+ log('unhandledRejection', reason, promise)
74
+
75
+ process.exit(1)
76
+ }
package/src/index.mjs ADDED
@@ -0,0 +1,26 @@
1
+ import process from 'node:process'
2
+
3
+ import {
4
+ handleSigHup,
5
+ handleSigInt,
6
+ handleSigBreak,
7
+ handleSigQuit,
8
+ handleSigTerm,
9
+ handleSigPipe,
10
+ handleBeforeExit,
11
+ handleExit,
12
+ handleUncaughtException,
13
+ handleUnhandledRejection
14
+ } from './common/index.mjs'
15
+
16
+ process
17
+ .on('SIGHUP', handleSigHup)
18
+ .on('SIGINT', handleSigInt)
19
+ .on('SIGBREAK', handleSigBreak)
20
+ .on('SIGQUIT', handleSigQuit)
21
+ .on('SIGTERM', handleSigTerm)
22
+ .on('SIGPIPE', handleSigPipe)
23
+ .on('beforeExit', handleBeforeExit)
24
+ .on('exit', handleExit)
25
+ .on('uncaughtException', handleUncaughtException)
26
+ .on('unhandledRejection', handleUnhandledRejection)