@sequencemedia/process 0.0.0 → 0.0.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequencemedia/process",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "description": "Node process handlers",
5
5
  "keywords": [
6
6
  "Node",
@@ -3,32 +3,41 @@ import process from 'node:process'
3
3
 
4
4
  const log = debug('@sequencemedia/process')
5
5
 
6
- export function handleSigHup (signal) {
7
- log('sigHup', signal)
6
+ function hasClearLine () {
7
+ const {
8
+ stdout
9
+ } = process
8
10
 
11
+ return 'clearLine' in stdout
12
+ }
13
+
14
+ function clearLine () {
9
15
  const {
10
16
  stdout
11
17
  } = process
12
18
 
13
- if ('clearLine' in stdout) {
14
- stdout.clearLine()
15
- stdout.cursorTo(0)
16
- }
19
+ stdout.clearLine()
20
+ stdout.cursorTo(0)
21
+ }
22
+
23
+ export function handleSigHup (signal) {
24
+ /**
25
+ * Clear the line before writing to `stdout`
26
+ */
27
+ if (hasClearLine()) clearLine()
28
+
29
+ log('sigHup', signal)
17
30
 
18
31
  process.exit(0)
19
32
  }
20
33
 
21
34
  export function handleSigInt (signal) {
22
- log('sigInt', signal)
35
+ /**
36
+ * Clear the line before writing to `stdout`
37
+ */
38
+ if (hasClearLine()) clearLine()
23
39
 
24
- const {
25
- stdout
26
- } = process
27
-
28
- if ('clearLine' in stdout) {
29
- stdout.clearLine()
30
- stdout.cursorTo(0)
31
- }
40
+ log('sigInt', signal)
32
41
 
33
42
  process.exit(0)
34
43
  }