@pnpm/exe 11.0.0-beta.0 → 11.0.0-beta.2

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.
Files changed (200) hide show
  1. package/dist/node_modules/@gar/promise-retry/lib/index.js +28 -0
  2. package/dist/node_modules/@gar/promise-retry/package.json +48 -0
  3. package/dist/node_modules/@npmcli/agent/package.json +7 -7
  4. package/dist/node_modules/@npmcli/fs/package.json +4 -4
  5. package/dist/node_modules/abbrev/package.json +11 -15
  6. package/dist/node_modules/cacache/package.json +10 -11
  7. package/dist/node_modules/glob/dist/commonjs/glob.js +2 -1
  8. package/dist/node_modules/glob/dist/commonjs/index.min.js +4 -0
  9. package/dist/node_modules/glob/dist/commonjs/pattern.js +4 -0
  10. package/dist/node_modules/glob/dist/esm/glob.js +2 -1
  11. package/dist/node_modules/glob/dist/esm/index.min.js +4 -0
  12. package/dist/node_modules/glob/dist/esm/pattern.js +4 -0
  13. package/dist/node_modules/glob/package.json +38 -37
  14. package/dist/node_modules/graceful-fs/graceful-fs.js +1 -1
  15. package/dist/node_modules/iconv-lite/encodings/dbcs-codec.js +460 -525
  16. package/dist/node_modules/iconv-lite/encodings/dbcs-data.js +179 -182
  17. package/dist/node_modules/iconv-lite/encodings/index.js +15 -15
  18. package/dist/node_modules/iconv-lite/encodings/internal.js +168 -148
  19. package/dist/node_modules/iconv-lite/encodings/sbcs-codec.js +55 -52
  20. package/dist/node_modules/iconv-lite/encodings/sbcs-data.js +174 -175
  21. package/dist/node_modules/iconv-lite/encodings/utf16.js +121 -131
  22. package/dist/node_modules/iconv-lite/encodings/utf32.js +226 -238
  23. package/dist/node_modules/iconv-lite/encodings/utf7.js +208 -215
  24. package/dist/node_modules/iconv-lite/lib/bom-handling.js +30 -34
  25. package/dist/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
  26. package/dist/node_modules/iconv-lite/lib/index.js +125 -123
  27. package/dist/node_modules/iconv-lite/lib/streams.js +92 -96
  28. package/dist/node_modules/iconv-lite/package.json +34 -8
  29. package/dist/node_modules/isexe/package.json +65 -18
  30. package/dist/node_modules/lru-cache/dist/commonjs/index.js +134 -85
  31. package/dist/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
  32. package/dist/node_modules/lru-cache/dist/esm/index.js +134 -85
  33. package/dist/node_modules/lru-cache/dist/esm/index.min.js +1 -1
  34. package/dist/node_modules/lru-cache/package.json +18 -41
  35. package/dist/node_modules/make-fetch-happen/lib/remote.js +1 -1
  36. package/dist/node_modules/make-fetch-happen/package.json +10 -10
  37. package/dist/node_modules/minipass-fetch/lib/body.js +25 -15
  38. package/dist/node_modules/minipass-fetch/package.json +7 -7
  39. package/dist/node_modules/minipass-sized/dist/commonjs/index.js +69 -0
  40. package/dist/node_modules/minipass-sized/dist/esm/index.js +64 -0
  41. package/dist/node_modules/minipass-sized/package.json +39 -9
  42. package/dist/node_modules/node-gyp/.release-please-manifest.json +1 -1
  43. package/dist/node_modules/node-gyp/bin/node-gyp.js +7 -0
  44. package/dist/node_modules/node-gyp/gyp/.release-please-manifest.json +1 -1
  45. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +3 -3
  46. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +26 -1
  47. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +1 -1
  48. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +3 -4
  49. package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +1 -1
  50. package/dist/node_modules/node-gyp/gyp/pyproject.toml +1 -1
  51. package/dist/node_modules/node-gyp/lib/build.js +2 -2
  52. package/dist/node_modules/node-gyp/lib/find-python.js +2 -8
  53. package/dist/node_modules/node-gyp/lib/find-visualstudio.js +11 -5
  54. package/dist/node_modules/node-gyp/lib/install.js +1 -1
  55. package/dist/node_modules/node-gyp/lib/process-release.js +3 -3
  56. package/dist/node_modules/node-gyp/package.json +13 -13
  57. package/dist/node_modules/nopt/package.json +5 -5
  58. package/dist/node_modules/proc-log/lib/index.js +10 -5
  59. package/dist/node_modules/proc-log/package.json +5 -5
  60. package/dist/node_modules/retry/lib/retry.js +2 -2
  61. package/dist/node_modules/retry/lib/retry_operation.js +10 -6
  62. package/dist/node_modules/retry/package.json +6 -2
  63. package/dist/node_modules/ssri/lib/index.js +33 -63
  64. package/dist/node_modules/ssri/package.json +17 -17
  65. package/dist/node_modules/unique-filename/package.json +5 -5
  66. package/dist/node_modules/unique-slug/package.json +4 -4
  67. package/dist/node_modules/which/package.json +29 -20
  68. package/dist/pnpm.mjs +63969 -54688
  69. package/dist/worker.js +601 -2162
  70. package/package.json +8 -8
  71. package/dist/node_modules/@isaacs/cliui/dist/commonjs/ansi-regex/index.js +0 -16
  72. package/dist/node_modules/@isaacs/cliui/dist/commonjs/ansi-styles/index.js +0 -170
  73. package/dist/node_modules/@isaacs/cliui/dist/commonjs/eastasianwidth/index.js +0 -307
  74. package/dist/node_modules/@isaacs/cliui/dist/commonjs/emoji-regex/index.js +0 -7
  75. package/dist/node_modules/@isaacs/cliui/dist/commonjs/index.js +0 -322
  76. package/dist/node_modules/@isaacs/cliui/dist/commonjs/index.min.js +0 -12
  77. package/dist/node_modules/@isaacs/cliui/dist/commonjs/string-width/index.js +0 -49
  78. package/dist/node_modules/@isaacs/cliui/dist/commonjs/strip-ansi/index.js +0 -8
  79. package/dist/node_modules/@isaacs/cliui/dist/commonjs/wrap-ansi/index.js +0 -176
  80. package/dist/node_modules/@isaacs/cliui/dist/esm/ansi-regex/index.js +0 -12
  81. package/dist/node_modules/@isaacs/cliui/dist/esm/ansi-styles/index.js +0 -167
  82. package/dist/node_modules/@isaacs/cliui/dist/esm/eastasianwidth/index.js +0 -299
  83. package/dist/node_modules/@isaacs/cliui/dist/esm/emoji-regex/index.js +0 -3
  84. package/dist/node_modules/@isaacs/cliui/dist/esm/index.js +0 -317
  85. package/dist/node_modules/@isaacs/cliui/dist/esm/index.min.js +0 -12
  86. package/dist/node_modules/@isaacs/cliui/dist/esm/string-width/index.js +0 -46
  87. package/dist/node_modules/@isaacs/cliui/dist/esm/strip-ansi/index.js +0 -4
  88. package/dist/node_modules/@isaacs/cliui/dist/esm/wrap-ansi/index.js +0 -172
  89. package/dist/node_modules/@isaacs/cliui/package.json +0 -163
  90. package/dist/node_modules/cross-spawn/LICENSE +0 -21
  91. package/dist/node_modules/cross-spawn/index.js +0 -39
  92. package/dist/node_modules/cross-spawn/lib/enoent.js +0 -59
  93. package/dist/node_modules/cross-spawn/lib/parse.js +0 -91
  94. package/dist/node_modules/cross-spawn/lib/util/escape.js +0 -47
  95. package/dist/node_modules/cross-spawn/lib/util/readShebang.js +0 -23
  96. package/dist/node_modules/cross-spawn/lib/util/resolveCommand.js +0 -52
  97. package/dist/node_modules/cross-spawn/package.json +0 -73
  98. package/dist/node_modules/encoding/.prettierrc.js +0 -8
  99. package/dist/node_modules/encoding/LICENSE +0 -16
  100. package/dist/node_modules/encoding/lib/encoding.js +0 -83
  101. package/dist/node_modules/encoding/package.json +0 -18
  102. package/dist/node_modules/err-code/.eslintrc.json +0 -7
  103. package/dist/node_modules/err-code/bower.json +0 -30
  104. package/dist/node_modules/err-code/index.js +0 -47
  105. package/dist/node_modules/err-code/index.umd.js +0 -51
  106. package/dist/node_modules/err-code/package.json +0 -34
  107. package/dist/node_modules/foreground-child/LICENSE +0 -15
  108. package/dist/node_modules/foreground-child/dist/commonjs/all-signals.js +0 -58
  109. package/dist/node_modules/foreground-child/dist/commonjs/index.js +0 -123
  110. package/dist/node_modules/foreground-child/dist/commonjs/proxy-signals.js +0 -38
  111. package/dist/node_modules/foreground-child/dist/commonjs/watchdog.js +0 -50
  112. package/dist/node_modules/foreground-child/dist/esm/all-signals.js +0 -52
  113. package/dist/node_modules/foreground-child/dist/esm/index.js +0 -115
  114. package/dist/node_modules/foreground-child/dist/esm/proxy-signals.js +0 -34
  115. package/dist/node_modules/foreground-child/dist/esm/watchdog.js +0 -46
  116. package/dist/node_modules/foreground-child/package.json +0 -106
  117. package/dist/node_modules/glob/dist/esm/bin.d.mts +0 -3
  118. package/dist/node_modules/glob/dist/esm/bin.mjs +0 -346
  119. package/dist/node_modules/iconv-lite/.github/dependabot.yml +0 -11
  120. package/dist/node_modules/iconv-lite/.idea/codeStyles/Project.xml +0 -47
  121. package/dist/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +0 -5
  122. package/dist/node_modules/iconv-lite/.idea/iconv-lite.iml +0 -12
  123. package/dist/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +0 -6
  124. package/dist/node_modules/iconv-lite/.idea/modules.xml +0 -8
  125. package/dist/node_modules/iconv-lite/.idea/vcs.xml +0 -6
  126. package/dist/node_modules/isexe/LICENSE +0 -15
  127. package/dist/node_modules/isexe/index.js +0 -57
  128. package/dist/node_modules/isexe/mode.js +0 -41
  129. package/dist/node_modules/isexe/windows.js +0 -42
  130. package/dist/node_modules/jackspeak/dist/commonjs/index.js +0 -944
  131. package/dist/node_modules/jackspeak/dist/commonjs/index.min.js +0 -33
  132. package/dist/node_modules/jackspeak/dist/commonjs/package.json +0 -3
  133. package/dist/node_modules/jackspeak/dist/esm/index.js +0 -936
  134. package/dist/node_modules/jackspeak/dist/esm/index.min.js +0 -33
  135. package/dist/node_modules/jackspeak/dist/esm/package.json +0 -3
  136. package/dist/node_modules/jackspeak/package.json +0 -115
  137. package/dist/node_modules/lru-cache/LICENSE +0 -15
  138. package/dist/node_modules/minipass-sized/index.js +0 -67
  139. package/dist/node_modules/minipass-sized/node_modules/minipass/LICENSE +0 -15
  140. package/dist/node_modules/minipass-sized/node_modules/minipass/index.js +0 -649
  141. package/dist/node_modules/minipass-sized/node_modules/minipass/package.json +0 -56
  142. package/dist/node_modules/minipass-sized/package-lock.json +0 -3464
  143. package/dist/node_modules/node-gyp/node_modules/isexe/dist/commonjs/package.json +0 -3
  144. package/dist/node_modules/node-gyp/node_modules/isexe/dist/esm/package.json +0 -3
  145. package/dist/node_modules/node-gyp/node_modules/isexe/package.json +0 -78
  146. package/dist/node_modules/node-gyp/node_modules/which/LICENSE +0 -15
  147. package/dist/node_modules/node-gyp/node_modules/which/package.json +0 -52
  148. package/dist/node_modules/package-json-from-dist/dist/commonjs/index.js +0 -134
  149. package/dist/node_modules/package-json-from-dist/dist/commonjs/package.json +0 -3
  150. package/dist/node_modules/package-json-from-dist/dist/esm/index.js +0 -129
  151. package/dist/node_modules/package-json-from-dist/dist/esm/package.json +0 -3
  152. package/dist/node_modules/package-json-from-dist/package.json +0 -68
  153. package/dist/node_modules/path-key/index.js +0 -16
  154. package/dist/node_modules/path-key/license +0 -9
  155. package/dist/node_modules/path-key/package.json +0 -39
  156. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js +0 -1589
  157. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js +0 -2
  158. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/package.json +0 -3
  159. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js +0 -1585
  160. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js +0 -2
  161. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/package.json +0 -3
  162. package/dist/node_modules/path-scurry/node_modules/lru-cache/package.json +0 -101
  163. package/dist/node_modules/promise-retry/index.js +0 -52
  164. package/dist/node_modules/promise-retry/package.json +0 -37
  165. package/dist/node_modules/retry/equation.gif +0 -0
  166. package/dist/node_modules/shebang-command/index.js +0 -19
  167. package/dist/node_modules/shebang-command/license +0 -9
  168. package/dist/node_modules/shebang-command/package.json +0 -34
  169. package/dist/node_modules/shebang-regex/index.js +0 -2
  170. package/dist/node_modules/shebang-regex/license +0 -9
  171. package/dist/node_modules/shebang-regex/package.json +0 -35
  172. package/dist/node_modules/signal-exit/LICENSE.txt +0 -16
  173. package/dist/node_modules/signal-exit/dist/cjs/browser.js +0 -10
  174. package/dist/node_modules/signal-exit/dist/cjs/index.js +0 -279
  175. package/dist/node_modules/signal-exit/dist/cjs/package.json +0 -3
  176. package/dist/node_modules/signal-exit/dist/cjs/signals.js +0 -42
  177. package/dist/node_modules/signal-exit/dist/mjs/browser.js +0 -4
  178. package/dist/node_modules/signal-exit/dist/mjs/index.js +0 -275
  179. package/dist/node_modules/signal-exit/dist/mjs/package.json +0 -3
  180. package/dist/node_modules/signal-exit/dist/mjs/signals.js +0 -39
  181. package/dist/node_modules/signal-exit/package.json +0 -106
  182. package/dist/node_modules/which/bin/node-which +0 -52
  183. package/dist/node_modules/which/which.js +0 -125
  184. /package/dist/node_modules/{promise-retry → @gar/promise-retry}/LICENSE +0 -0
  185. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/index.js +0 -0
  186. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/index.min.js +0 -0
  187. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/options.js +0 -0
  188. /package/dist/node_modules/{@isaacs/cliui → isexe}/dist/commonjs/package.json +0 -0
  189. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/posix.js +0 -0
  190. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/win32.js +0 -0
  191. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/index.js +0 -0
  192. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/index.min.js +0 -0
  193. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/options.js +0 -0
  194. /package/dist/node_modules/{@isaacs/cliui → isexe}/dist/esm/package.json +0 -0
  195. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/posix.js +0 -0
  196. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/win32.js +0 -0
  197. /package/dist/node_modules/{foreground-child → minipass-sized}/dist/commonjs/package.json +0 -0
  198. /package/dist/node_modules/{foreground-child → minipass-sized}/dist/esm/package.json +0 -0
  199. /package/dist/node_modules/{node-gyp/node_modules/which → which}/bin/which.js +0 -0
  200. /package/dist/node_modules/{node-gyp/node_modules/which → which}/lib/index.js +0 -0
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.signals = void 0;
4
- /**
5
- * This is not the set of all possible signals.
6
- *
7
- * It IS, however, the set of all signals that trigger
8
- * an exit on either Linux or BSD systems. Linux is a
9
- * superset of the signal names supported on BSD, and
10
- * the unknown signals just fail to register, so we can
11
- * catch that easily enough.
12
- *
13
- * Windows signals are a different set, since there are
14
- * signals that terminate Windows processes, but don't
15
- * terminate (or don't even exist) on Posix systems.
16
- *
17
- * Don't bother with SIGKILL. It's uncatchable, which
18
- * means that we can't fire any callbacks anyway.
19
- *
20
- * If a user does happen to register a handler on a non-
21
- * fatal signal like SIGWINCH or something, and then
22
- * exit, it'll end up firing `process.emit('exit')`, so
23
- * the handler will be fired anyway.
24
- *
25
- * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
26
- * artificially, inherently leave the process in a
27
- * state from which it is not safe to try and enter JS
28
- * listeners.
29
- */
30
- exports.signals = [];
31
- exports.signals.push('SIGHUP', 'SIGINT', 'SIGTERM');
32
- if (process.platform !== 'win32') {
33
- exports.signals.push('SIGALRM', 'SIGABRT', 'SIGVTALRM', 'SIGXCPU', 'SIGXFSZ', 'SIGUSR2', 'SIGTRAP', 'SIGSYS', 'SIGQUIT', 'SIGIOT'
34
- // should detect profiler and enable/disable accordingly.
35
- // see #21
36
- // 'SIGPROF'
37
- );
38
- }
39
- if (process.platform === 'linux') {
40
- exports.signals.push('SIGIO', 'SIGPOLL', 'SIGPWR', 'SIGSTKFLT');
41
- }
42
- //# sourceMappingURL=signals.js.map
@@ -1,4 +0,0 @@
1
- export const onExit = () => () => { };
2
- export const load = () => { };
3
- export const unload = () => { };
4
- //# sourceMappingURL=browser.js.map
@@ -1,275 +0,0 @@
1
- // Note: since nyc uses this module to output coverage, any lines
2
- // that are in the direct sync flow of nyc's outputCoverage are
3
- // ignored, since we can never get coverage for them.
4
- // grab a reference to node's real process object right away
5
- import { signals } from './signals.js';
6
- export { signals };
7
- const processOk = (process) => !!process &&
8
- typeof process === 'object' &&
9
- typeof process.removeListener === 'function' &&
10
- typeof process.emit === 'function' &&
11
- typeof process.reallyExit === 'function' &&
12
- typeof process.listeners === 'function' &&
13
- typeof process.kill === 'function' &&
14
- typeof process.pid === 'number' &&
15
- typeof process.on === 'function';
16
- const kExitEmitter = Symbol.for('signal-exit emitter');
17
- const global = globalThis;
18
- const ObjectDefineProperty = Object.defineProperty.bind(Object);
19
- // teeny special purpose ee
20
- class Emitter {
21
- emitted = {
22
- afterExit: false,
23
- exit: false,
24
- };
25
- listeners = {
26
- afterExit: [],
27
- exit: [],
28
- };
29
- count = 0;
30
- id = Math.random();
31
- constructor() {
32
- if (global[kExitEmitter]) {
33
- return global[kExitEmitter];
34
- }
35
- ObjectDefineProperty(global, kExitEmitter, {
36
- value: this,
37
- writable: false,
38
- enumerable: false,
39
- configurable: false,
40
- });
41
- }
42
- on(ev, fn) {
43
- this.listeners[ev].push(fn);
44
- }
45
- removeListener(ev, fn) {
46
- const list = this.listeners[ev];
47
- const i = list.indexOf(fn);
48
- /* c8 ignore start */
49
- if (i === -1) {
50
- return;
51
- }
52
- /* c8 ignore stop */
53
- if (i === 0 && list.length === 1) {
54
- list.length = 0;
55
- }
56
- else {
57
- list.splice(i, 1);
58
- }
59
- }
60
- emit(ev, code, signal) {
61
- if (this.emitted[ev]) {
62
- return false;
63
- }
64
- this.emitted[ev] = true;
65
- let ret = false;
66
- for (const fn of this.listeners[ev]) {
67
- ret = fn(code, signal) === true || ret;
68
- }
69
- if (ev === 'exit') {
70
- ret = this.emit('afterExit', code, signal) || ret;
71
- }
72
- return ret;
73
- }
74
- }
75
- class SignalExitBase {
76
- }
77
- const signalExitWrap = (handler) => {
78
- return {
79
- onExit(cb, opts) {
80
- return handler.onExit(cb, opts);
81
- },
82
- load() {
83
- return handler.load();
84
- },
85
- unload() {
86
- return handler.unload();
87
- },
88
- };
89
- };
90
- class SignalExitFallback extends SignalExitBase {
91
- onExit() {
92
- return () => { };
93
- }
94
- load() { }
95
- unload() { }
96
- }
97
- class SignalExit extends SignalExitBase {
98
- // "SIGHUP" throws an `ENOSYS` error on Windows,
99
- // so use a supported signal instead
100
- /* c8 ignore start */
101
- #hupSig = process.platform === 'win32' ? 'SIGINT' : 'SIGHUP';
102
- /* c8 ignore stop */
103
- #emitter = new Emitter();
104
- #process;
105
- #originalProcessEmit;
106
- #originalProcessReallyExit;
107
- #sigListeners = {};
108
- #loaded = false;
109
- constructor(process) {
110
- super();
111
- this.#process = process;
112
- // { <signal>: <listener fn>, ... }
113
- this.#sigListeners = {};
114
- for (const sig of signals) {
115
- this.#sigListeners[sig] = () => {
116
- // If there are no other listeners, an exit is coming!
117
- // Simplest way: remove us and then re-send the signal.
118
- // We know that this will kill the process, so we can
119
- // safely emit now.
120
- const listeners = this.#process.listeners(sig);
121
- let { count } = this.#emitter;
122
- // This is a workaround for the fact that signal-exit v3 and signal
123
- // exit v4 are not aware of each other, and each will attempt to let
124
- // the other handle it, so neither of them do. To correct this, we
125
- // detect if we're the only handler *except* for previous versions
126
- // of signal-exit, and increment by the count of listeners it has
127
- // created.
128
- /* c8 ignore start */
129
- const p = process;
130
- if (typeof p.__signal_exit_emitter__ === 'object' &&
131
- typeof p.__signal_exit_emitter__.count === 'number') {
132
- count += p.__signal_exit_emitter__.count;
133
- }
134
- /* c8 ignore stop */
135
- if (listeners.length === count) {
136
- this.unload();
137
- const ret = this.#emitter.emit('exit', null, sig);
138
- /* c8 ignore start */
139
- const s = sig === 'SIGHUP' ? this.#hupSig : sig;
140
- if (!ret)
141
- process.kill(process.pid, s);
142
- /* c8 ignore stop */
143
- }
144
- };
145
- }
146
- this.#originalProcessReallyExit = process.reallyExit;
147
- this.#originalProcessEmit = process.emit;
148
- }
149
- onExit(cb, opts) {
150
- /* c8 ignore start */
151
- if (!processOk(this.#process)) {
152
- return () => { };
153
- }
154
- /* c8 ignore stop */
155
- if (this.#loaded === false) {
156
- this.load();
157
- }
158
- const ev = opts?.alwaysLast ? 'afterExit' : 'exit';
159
- this.#emitter.on(ev, cb);
160
- return () => {
161
- this.#emitter.removeListener(ev, cb);
162
- if (this.#emitter.listeners['exit'].length === 0 &&
163
- this.#emitter.listeners['afterExit'].length === 0) {
164
- this.unload();
165
- }
166
- };
167
- }
168
- load() {
169
- if (this.#loaded) {
170
- return;
171
- }
172
- this.#loaded = true;
173
- // This is the number of onSignalExit's that are in play.
174
- // It's important so that we can count the correct number of
175
- // listeners on signals, and don't wait for the other one to
176
- // handle it instead of us.
177
- this.#emitter.count += 1;
178
- for (const sig of signals) {
179
- try {
180
- const fn = this.#sigListeners[sig];
181
- if (fn)
182
- this.#process.on(sig, fn);
183
- }
184
- catch (_) { }
185
- }
186
- this.#process.emit = (ev, ...a) => {
187
- return this.#processEmit(ev, ...a);
188
- };
189
- this.#process.reallyExit = (code) => {
190
- return this.#processReallyExit(code);
191
- };
192
- }
193
- unload() {
194
- if (!this.#loaded) {
195
- return;
196
- }
197
- this.#loaded = false;
198
- signals.forEach(sig => {
199
- const listener = this.#sigListeners[sig];
200
- /* c8 ignore start */
201
- if (!listener) {
202
- throw new Error('Listener not defined for signal: ' + sig);
203
- }
204
- /* c8 ignore stop */
205
- try {
206
- this.#process.removeListener(sig, listener);
207
- /* c8 ignore start */
208
- }
209
- catch (_) { }
210
- /* c8 ignore stop */
211
- });
212
- this.#process.emit = this.#originalProcessEmit;
213
- this.#process.reallyExit = this.#originalProcessReallyExit;
214
- this.#emitter.count -= 1;
215
- }
216
- #processReallyExit(code) {
217
- /* c8 ignore start */
218
- if (!processOk(this.#process)) {
219
- return 0;
220
- }
221
- this.#process.exitCode = code || 0;
222
- /* c8 ignore stop */
223
- this.#emitter.emit('exit', this.#process.exitCode, null);
224
- return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
225
- }
226
- #processEmit(ev, ...args) {
227
- const og = this.#originalProcessEmit;
228
- if (ev === 'exit' && processOk(this.#process)) {
229
- if (typeof args[0] === 'number') {
230
- this.#process.exitCode = args[0];
231
- /* c8 ignore start */
232
- }
233
- /* c8 ignore start */
234
- const ret = og.call(this.#process, ev, ...args);
235
- /* c8 ignore start */
236
- this.#emitter.emit('exit', this.#process.exitCode, null);
237
- /* c8 ignore stop */
238
- return ret;
239
- }
240
- else {
241
- return og.call(this.#process, ev, ...args);
242
- }
243
- }
244
- }
245
- const process = globalThis.process;
246
- // wrap so that we call the method on the actual handler, without
247
- // exporting it directly.
248
- export const {
249
- /**
250
- * Called when the process is exiting, whether via signal, explicit
251
- * exit, or running out of stuff to do.
252
- *
253
- * If the global process object is not suitable for instrumentation,
254
- * then this will be a no-op.
255
- *
256
- * Returns a function that may be used to unload signal-exit.
257
- */
258
- onExit,
259
- /**
260
- * Load the listeners. Likely you never need to call this, unless
261
- * doing a rather deep integration with signal-exit functionality.
262
- * Mostly exposed for the benefit of testing.
263
- *
264
- * @internal
265
- */
266
- load,
267
- /**
268
- * Unload the listeners. Likely you never need to call this, unless
269
- * doing a rather deep integration with signal-exit functionality.
270
- * Mostly exposed for the benefit of testing.
271
- *
272
- * @internal
273
- */
274
- unload, } = signalExitWrap(processOk(process) ? new SignalExit(process) : new SignalExitFallback());
275
- //# sourceMappingURL=index.js.map
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
@@ -1,39 +0,0 @@
1
- /**
2
- * This is not the set of all possible signals.
3
- *
4
- * It IS, however, the set of all signals that trigger
5
- * an exit on either Linux or BSD systems. Linux is a
6
- * superset of the signal names supported on BSD, and
7
- * the unknown signals just fail to register, so we can
8
- * catch that easily enough.
9
- *
10
- * Windows signals are a different set, since there are
11
- * signals that terminate Windows processes, but don't
12
- * terminate (or don't even exist) on Posix systems.
13
- *
14
- * Don't bother with SIGKILL. It's uncatchable, which
15
- * means that we can't fire any callbacks anyway.
16
- *
17
- * If a user does happen to register a handler on a non-
18
- * fatal signal like SIGWINCH or something, and then
19
- * exit, it'll end up firing `process.emit('exit')`, so
20
- * the handler will be fired anyway.
21
- *
22
- * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
23
- * artificially, inherently leave the process in a
24
- * state from which it is not safe to try and enter JS
25
- * listeners.
26
- */
27
- export const signals = [];
28
- signals.push('SIGHUP', 'SIGINT', 'SIGTERM');
29
- if (process.platform !== 'win32') {
30
- signals.push('SIGALRM', 'SIGABRT', 'SIGVTALRM', 'SIGXCPU', 'SIGXFSZ', 'SIGUSR2', 'SIGTRAP', 'SIGSYS', 'SIGQUIT', 'SIGIOT'
31
- // should detect profiler and enable/disable accordingly.
32
- // see #21
33
- // 'SIGPROF'
34
- );
35
- }
36
- if (process.platform === 'linux') {
37
- signals.push('SIGIO', 'SIGPOLL', 'SIGPWR', 'SIGSTKFLT');
38
- }
39
- //# sourceMappingURL=signals.js.map
@@ -1,106 +0,0 @@
1
- {
2
- "name": "signal-exit",
3
- "version": "4.1.0",
4
- "description": "when you want to fire an event no matter how a process exits.",
5
- "main": "./dist/cjs/index.js",
6
- "module": "./dist/mjs/index.js",
7
- "browser": "./dist/mjs/browser.js",
8
- "types": "./dist/mjs/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "import": {
12
- "types": "./dist/mjs/index.d.ts",
13
- "default": "./dist/mjs/index.js"
14
- },
15
- "require": {
16
- "types": "./dist/cjs/index.d.ts",
17
- "default": "./dist/cjs/index.js"
18
- }
19
- },
20
- "./signals": {
21
- "import": {
22
- "types": "./dist/mjs/signals.d.ts",
23
- "default": "./dist/mjs/signals.js"
24
- },
25
- "require": {
26
- "types": "./dist/cjs/signals.d.ts",
27
- "default": "./dist/cjs/signals.js"
28
- }
29
- },
30
- "./browser": {
31
- "import": {
32
- "types": "./dist/mjs/browser.d.ts",
33
- "default": "./dist/mjs/browser.js"
34
- },
35
- "require": {
36
- "types": "./dist/cjs/browser.d.ts",
37
- "default": "./dist/cjs/browser.js"
38
- }
39
- }
40
- },
41
- "files": [
42
- "dist"
43
- ],
44
- "engines": {
45
- "node": ">=14"
46
- },
47
- "repository": {
48
- "type": "git",
49
- "url": "https://github.com/tapjs/signal-exit.git"
50
- },
51
- "keywords": [
52
- "signal",
53
- "exit"
54
- ],
55
- "author": "Ben Coe <ben@npmjs.com>",
56
- "license": "ISC",
57
- "devDependencies": {
58
- "@types/cross-spawn": "^6.0.2",
59
- "@types/node": "^18.15.11",
60
- "@types/signal-exit": "^3.0.1",
61
- "@types/tap": "^15.0.8",
62
- "c8": "^7.13.0",
63
- "prettier": "^2.8.6",
64
- "tap": "^16.3.4",
65
- "ts-node": "^10.9.1",
66
- "typedoc": "^0.23.28",
67
- "typescript": "^5.0.2"
68
- },
69
- "scripts": {
70
- "preversion": "npm test",
71
- "postversion": "npm publish",
72
- "prepublishOnly": "git push origin --follow-tags",
73
- "preprepare": "rm -rf dist",
74
- "prepare": "tsc -p tsconfig.json && tsc -p tsconfig-esm.json && bash ./scripts/fixup.sh",
75
- "pretest": "npm run prepare",
76
- "presnap": "npm run prepare",
77
- "test": "c8 tap",
78
- "snap": "c8 tap",
79
- "format": "prettier --write . --loglevel warn",
80
- "typedoc": "typedoc --tsconfig tsconfig-esm.json ./src/*.ts"
81
- },
82
- "prettier": {
83
- "semi": false,
84
- "printWidth": 75,
85
- "tabWidth": 2,
86
- "useTabs": false,
87
- "singleQuote": true,
88
- "jsxSingleQuote": false,
89
- "bracketSameLine": true,
90
- "arrowParens": "avoid",
91
- "endOfLine": "lf"
92
- },
93
- "tap": {
94
- "coverage": false,
95
- "jobs": 1,
96
- "node-arg": [
97
- "--no-warnings",
98
- "--loader",
99
- "ts-node/esm"
100
- ],
101
- "ts": false
102
- },
103
- "funding": {
104
- "url": "https://github.com/sponsors/isaacs"
105
- }
106
- }
@@ -1,52 +0,0 @@
1
- #!/usr/bin/env node
2
- var which = require("../")
3
- if (process.argv.length < 3)
4
- usage()
5
-
6
- function usage () {
7
- console.error('usage: which [-as] program ...')
8
- process.exit(1)
9
- }
10
-
11
- var all = false
12
- var silent = false
13
- var dashdash = false
14
- var args = process.argv.slice(2).filter(function (arg) {
15
- if (dashdash || !/^-/.test(arg))
16
- return true
17
-
18
- if (arg === '--') {
19
- dashdash = true
20
- return false
21
- }
22
-
23
- var flags = arg.substr(1).split('')
24
- for (var f = 0; f < flags.length; f++) {
25
- var flag = flags[f]
26
- switch (flag) {
27
- case 's':
28
- silent = true
29
- break
30
- case 'a':
31
- all = true
32
- break
33
- default:
34
- console.error('which: illegal option -- ' + flag)
35
- usage()
36
- }
37
- }
38
- return false
39
- })
40
-
41
- process.exit(args.reduce(function (pv, current) {
42
- try {
43
- var f = which.sync(current, { all: all })
44
- if (all)
45
- f = f.join('\n')
46
- if (!silent)
47
- console.log(f)
48
- return pv;
49
- } catch (e) {
50
- return 1;
51
- }
52
- }, 0))
@@ -1,125 +0,0 @@
1
- const isWindows = process.platform === 'win32' ||
2
- process.env.OSTYPE === 'cygwin' ||
3
- process.env.OSTYPE === 'msys'
4
-
5
- const path = require('path')
6
- const COLON = isWindows ? ';' : ':'
7
- const isexe = require('isexe')
8
-
9
- const getNotFoundError = (cmd) =>
10
- Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })
11
-
12
- const getPathInfo = (cmd, opt) => {
13
- const colon = opt.colon || COLON
14
-
15
- // If it has a slash, then we don't bother searching the pathenv.
16
- // just check the file itself, and that's it.
17
- const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? ['']
18
- : (
19
- [
20
- // windows always checks the cwd first
21
- ...(isWindows ? [process.cwd()] : []),
22
- ...(opt.path || process.env.PATH ||
23
- /* istanbul ignore next: very unusual */ '').split(colon),
24
- ]
25
- )
26
- const pathExtExe = isWindows
27
- ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'
28
- : ''
29
- const pathExt = isWindows ? pathExtExe.split(colon) : ['']
30
-
31
- if (isWindows) {
32
- if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
33
- pathExt.unshift('')
34
- }
35
-
36
- return {
37
- pathEnv,
38
- pathExt,
39
- pathExtExe,
40
- }
41
- }
42
-
43
- const which = (cmd, opt, cb) => {
44
- if (typeof opt === 'function') {
45
- cb = opt
46
- opt = {}
47
- }
48
- if (!opt)
49
- opt = {}
50
-
51
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
52
- const found = []
53
-
54
- const step = i => new Promise((resolve, reject) => {
55
- if (i === pathEnv.length)
56
- return opt.all && found.length ? resolve(found)
57
- : reject(getNotFoundError(cmd))
58
-
59
- const ppRaw = pathEnv[i]
60
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
61
-
62
- const pCmd = path.join(pathPart, cmd)
63
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
64
- : pCmd
65
-
66
- resolve(subStep(p, i, 0))
67
- })
68
-
69
- const subStep = (p, i, ii) => new Promise((resolve, reject) => {
70
- if (ii === pathExt.length)
71
- return resolve(step(i + 1))
72
- const ext = pathExt[ii]
73
- isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
74
- if (!er && is) {
75
- if (opt.all)
76
- found.push(p + ext)
77
- else
78
- return resolve(p + ext)
79
- }
80
- return resolve(subStep(p, i, ii + 1))
81
- })
82
- })
83
-
84
- return cb ? step(0).then(res => cb(null, res), cb) : step(0)
85
- }
86
-
87
- const whichSync = (cmd, opt) => {
88
- opt = opt || {}
89
-
90
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
91
- const found = []
92
-
93
- for (let i = 0; i < pathEnv.length; i ++) {
94
- const ppRaw = pathEnv[i]
95
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
96
-
97
- const pCmd = path.join(pathPart, cmd)
98
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
99
- : pCmd
100
-
101
- for (let j = 0; j < pathExt.length; j ++) {
102
- const cur = p + pathExt[j]
103
- try {
104
- const is = isexe.sync(cur, { pathExt: pathExtExe })
105
- if (is) {
106
- if (opt.all)
107
- found.push(cur)
108
- else
109
- return cur
110
- }
111
- } catch (ex) {}
112
- }
113
- }
114
-
115
- if (opt.all && found.length)
116
- return found
117
-
118
- if (opt.nothrow)
119
- return null
120
-
121
- throw getNotFoundError(cmd)
122
- }
123
-
124
- module.exports = which
125
- which.sync = whichSync