Commit 10caf5b
committed
refactor: standardize run-command.mjs error handling
Added proper error handling to all command execution functions:
- runCommand: Added try/catch to handle non-zero exits from lib spawn
- runCommandSync: Standardized shell options pattern
- runCommandQuiet: Added try/catch for consistent error handling
Changed shell option pattern from:
shell: process.platform === 'win32'
To:
...(process.platform === 'win32' && { shell: true })
This matches the pattern used in socket-sdk-js and socket-packageurl-js,
ensuring consistent behavior across all socket-* repositories.
Benefits:
- Proper error handling prevents unhandled promise rejections
- Consistent shell options pattern across repos
- Better compatibility with @socketsecurity/lib/spawn behavior1 parent 4d3c5cf commit 10caf5b
1 file changed
+46
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
23 | 32 | | |
24 | 33 | | |
25 | 34 | | |
| |||
31 | 40 | | |
32 | 41 | | |
33 | 42 | | |
34 | | - | |
35 | 43 | | |
| 44 | + | |
36 | 45 | | |
37 | 46 | | |
| 47 | + | |
38 | 48 | | |
39 | 49 | | |
40 | 50 | | |
| |||
85 | 95 | | |
86 | 96 | | |
87 | 97 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
94 | 105 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
99 | 128 | | |
100 | 129 | | |
101 | 130 | | |
| |||
0 commit comments