@idlebox/node 1.4.11 → 1.4.12

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/src/autoindex.ts CHANGED
@@ -3,151 +3,162 @@
3
3
  /* eslint-disable */
4
4
 
5
5
  /* asyncLoad.ts */
6
- // Identifiers
7
- export type { AsyncMainFunction } from './asyncLoad.js';
8
- export { executeMainFunction } from './asyncLoad.js';
6
+ // Identifiers
7
+ export type { AsyncMainFunction } from "./asyncLoad.js";
8
+ export { executeMainFunction } from "./asyncLoad.js";
9
9
  /* preload.ts */
10
- // Identifiers
10
+ // Identifiers
11
11
  /* child_process/error.ts */
12
- // Identifiers
13
- export { checkChildProcessResult } from './child_process/error.js';
12
+ // Identifiers
13
+ export { checkChildProcessResult } from "./child_process/error.js";
14
14
  /* child_process/execa.ts */
15
- // Identifiers
16
- export type { ICommand } from './child_process/execa.js';
17
- export { spawnWithoutOutputSync } from './child_process/execa.js';
18
- export { spawnWithoutOutput } from './child_process/execa.js';
19
- export { spawnGetOutputSync } from './child_process/execa.js';
20
- export { spawnGetOutput } from './child_process/execa.js';
21
- export { spawnGetEverything } from './child_process/execa.js';
15
+ // Identifiers
16
+ export type { ICommand } from "./child_process/execa.js";
17
+ export { spawnWithoutOutputSync } from "./child_process/execa.js";
18
+ export { spawnWithoutOutput } from "./child_process/execa.js";
19
+ export { spawnGetOutputSync } from "./child_process/execa.js";
20
+ export { spawnGetOutput } from "./child_process/execa.js";
21
+ export { spawnGetEverything } from "./child_process/execa.js";
22
22
  /* cli-io/output.ts */
23
- // Identifiers
24
- export { printLine } from './cli-io/output.js';
23
+ // Identifiers
24
+ export { printLine } from "./cli-io/output.js";
25
25
  /* child_process/lateError.ts */
26
- // Identifiers
27
- export type { ISpawnOptions } from './child_process/lateError.js';
28
- export type { ExecaReturnValue } from './child_process/lateError.js';
29
- export { execLazyError } from './child_process/lateError.js';
26
+ // Identifiers
27
+ export type { ISpawnOptions } from "./child_process/lateError.js";
28
+ export type { ExecaReturnValue } from "./child_process/lateError.js";
29
+ export { execLazyError } from "./child_process/lateError.js";
30
30
  /* error/linux.ts */
31
- // Identifiers
32
- export { LinuxError } from './error/linux.js';
31
+ // Identifiers
32
+ export { LinuxError } from "./error/linux.js";
33
33
  /* error/types.ts */
34
- // Identifiers
35
- export type { OpenSSLException } from './error/types.js';
36
- export { isModuleResolutionError } from './error/types.js';
37
- export { isNotExistsError } from './error/types.js';
38
- export { isExistsError } from './error/types.js';
39
- export { isTypeError } from './error/types.js';
40
- export { isFileTypeError } from './error/types.js';
41
- export { isNodeError } from './error/types.js';
42
- // References
43
- export * from '@idlebox/node-error-codes';
34
+ // Identifiers
35
+ export type { OpenSSLException } from "./error/types.js";
36
+ export { isModuleResolutionError } from "./error/types.js";
37
+ export { isNotExistsError } from "./error/types.js";
38
+ export { isExistsError } from "./error/types.js";
39
+ export { isTypeError } from "./error/types.js";
40
+ export { isFileTypeError } from "./error/types.js";
41
+ export { isNodeError } from "./error/types.js";
42
+ // References
43
+ export * from "@idlebox/node-error-codes";
44
44
  /* fs/exists.ts */
45
- // Identifiers
46
- export { existsSync } from './fs/exists.js';
47
- export { exists } from './fs/exists.js';
48
- export { readFileIfExists } from './fs/exists.js';
45
+ // Identifiers
46
+ export { existsSync } from "./fs/exists.js";
47
+ export { exists } from "./fs/exists.js";
48
+ export { readFileIfExists } from "./fs/exists.js";
49
49
  /* environment/getEnvironment.ts */
50
- // Identifiers
51
- export type { IEnvironmentResult } from './environment/getEnvironment.js';
52
- export { getEnvironment } from './environment/getEnvironment.js';
53
- export { deleteEnvironment } from './environment/getEnvironment.js';
54
- export { cleanupEnvironment } from './environment/getEnvironment.js';
50
+ // Identifiers
51
+ export type { IEnvironmentResult } from "./environment/getEnvironment.js";
52
+ export { getEnvironment } from "./environment/getEnvironment.js";
53
+ export { deleteEnvironment } from "./environment/getEnvironment.js";
54
+ export { cleanupEnvironment } from "./environment/getEnvironment.js";
55
55
  /* environment/pathEnvironment.ts */
56
- // Identifiers
57
- export { PATH_SEPARATOR } from './environment/pathEnvironment.js';
58
- export { PathEnvironment } from './environment/pathEnvironment.js';
56
+ // Identifiers
57
+ export { PATH_SEPARATOR } from "./environment/pathEnvironment.js";
58
+ export { PathEnvironment } from "./environment/pathEnvironment.js";
59
59
  /* environment/findBinary.ts */
60
- // Identifiers
61
- export { findBinary } from './environment/findBinary.js';
60
+ // Identifiers
61
+ export { findBinary } from "./environment/findBinary.js";
62
62
  /* child_process/respawn.ts */
63
- // Identifiers
64
- export { spawnRecreateEventHandlers } from './child_process/respawn.js';
65
- export { trySpawnInScope } from './child_process/respawn.js';
66
- export { respawnInScope } from './child_process/respawn.js';
63
+ // Identifiers
64
+ export { spawnRecreateEventHandlers } from "./child_process/respawn.js";
65
+ export { trySpawnInScope } from "./child_process/respawn.js";
66
+ export { respawnInScope } from "./child_process/respawn.js";
67
67
  /* crypto/md5.ts */
68
- // Identifiers
69
- export { md5 } from './crypto/md5.js';
68
+ // Identifiers
69
+ export { md5 } from "./crypto/md5.js";
70
70
  /* crypto/sha256.ts */
71
- // Identifiers
72
- export { sha256 } from './crypto/sha256.js';
71
+ // Identifiers
72
+ export { sha256 } from "./crypto/sha256.js";
73
73
  /* environment/npmConfig.ts */
74
- // Identifiers
75
- export { getNpmConfigValue } from './environment/npmConfig.js';
74
+ // Identifiers
75
+ export { getNpmConfigValue } from "./environment/npmConfig.js";
76
76
  /* events/dumpEventEmitter.ts */
77
- // Identifiers
78
- export { dumpEventEmitterEmit } from './events/dumpEventEmitter.js';
77
+ // Identifiers
78
+ export { dumpEventEmitterEmit } from "./events/dumpEventEmitter.js";
79
79
  /* fs/commandExists.ts */
80
- // Identifiers
81
- export { commandInPath } from './fs/commandExists.js';
82
- export { commandInPathSync } from './fs/commandExists.js';
80
+ // Identifiers
81
+ export { commandInPath } from "./fs/commandExists.js";
82
+ export { commandInPathSync } from "./fs/commandExists.js";
83
83
  /* fs/emptyDir.ts */
84
- // Identifiers
85
- export { emptyDir } from './fs/emptyDir.js';
84
+ // Identifiers
85
+ export { emptyDir } from "./fs/emptyDir.js";
86
86
  /* fs/ensureDir.ts */
87
- // Identifiers
88
- export { ensureDirExists } from './fs/ensureDir.js';
89
- export { ensureParentExists } from './fs/ensureDir.js';
87
+ // Identifiers
88
+ export { ensureDirExists } from "./fs/ensureDir.js";
89
+ export { ensureParentExists } from "./fs/ensureDir.js";
90
90
  /* fs/tempFolder.ts */
91
- // Identifiers
92
- export { createTempFolder } from './fs/tempFolder.js';
91
+ // Identifiers
92
+ export { createTempFolder } from "./fs/tempFolder.js";
93
93
  /* fs/weiteChanged.ts */
94
- // Identifiers
95
- export { writeFileIfChangeSync } from './fs/weiteChanged.js';
96
- export { writeFileIfChange } from './fs/weiteChanged.js';
94
+ // Identifiers
95
+ export { writeFileIfChangeSync } from "./fs/weiteChanged.js";
96
+ export { writeFileIfChange } from "./fs/weiteChanged.js";
97
+ /* lifecycle/internal-errors.ts */
98
+ // Identifiers
99
+ export { Exit } from "./lifecycle/internal-errors.js";
100
+ export { InterruptError } from "./lifecycle/internal-errors.js";
101
+ export { UnhandledRejection } from "./lifecycle/internal-errors.js";
102
+ export { UncaughtException } from "./lifecycle/internal-errors.js";
97
103
  /* lifecycle/register.ts */
98
- // Identifiers
99
- export { shutdown } from './lifecycle/register.js';
100
- export { registerNodejsExitHandler } from './lifecycle/register.js';
101
- export { die } from './lifecycle/register.js';
104
+ // Identifiers
105
+ export { setAbnormalExitCode } from "./lifecycle/register.js";
106
+ export { shutdown } from "./lifecycle/register.js";
107
+ export { registerNodejsGlobalTypedErrorHandlerWithInheritance } from "./lifecycle/register.js";
108
+ export { registerNodejsGlobalTypedErrorHandler } from "./lifecycle/register.js";
109
+ export { registerNodejsExitHandler } from "./lifecycle/register.js";
110
+ export { die } from "./lifecycle/register.js";
102
111
  /* log/terminal.ts */
103
- // Identifiers
104
- export { WrappedTerminalConsole } from './log/terminal.js';
112
+ // Identifiers
113
+ export { WrappedTerminalConsole } from "./log/terminal.js";
105
114
  /* path-resolve/findUp.ts */
106
- // Identifiers
107
- export type { IFindOptions } from './path-resolve/findUp.js';
108
- export { findUpUntil } from './path-resolve/findUp.js';
109
- export { findUpUntilSync } from './path-resolve/findUp.js';
115
+ // Identifiers
116
+ export type { IFindOptions } from "./path-resolve/findUp.js";
117
+ export { findUpUntil } from "./path-resolve/findUp.js";
118
+ export { findUp } from "./path-resolve/findUp.js";
119
+ export { findUpUntilSync } from "./path-resolve/findUp.js";
120
+ export { findUpSync } from "./path-resolve/findUp.js";
110
121
  /* path-resolve/findPackageRoot.ts */
111
- // Identifiers
112
- export { findPackageRoot } from './path-resolve/findPackageRoot.js';
122
+ // Identifiers
123
+ export { findPackageRoot } from "./path-resolve/findPackageRoot.js";
113
124
  /* path-resolve/getAllUp.ts */
114
- // Identifiers
115
- export { getAllPathUpToRoot } from './path-resolve/getAllUp.js';
125
+ // Identifiers
126
+ export { getAllPathUpToRoot } from "./path-resolve/getAllUp.js";
116
127
  /* path-resolve/lrelative.ts */
117
- // Identifiers
118
- export { lrelative } from './path-resolve/lrelative.js';
128
+ // Identifiers
129
+ export { lrelative } from "./path-resolve/lrelative.js";
119
130
  /* path-resolve/nodeResolvePathArray.ts */
120
- // Identifiers
121
- export { nodeResolvePathArray } from './path-resolve/nodeResolvePathArray.js';
131
+ // Identifiers
132
+ export { nodeResolvePathArray } from "./path-resolve/nodeResolvePathArray.js";
122
133
  /* path-resolve/resolvePath.ts */
123
- // Identifiers
124
- export type { ResolvePathFunction } from './path-resolve/resolvePath.js';
125
- export type { JoinPathFunction } from './path-resolve/resolvePath.js';
126
- export { resolvePath } from './path-resolve/resolvePath.js';
127
- export type { NormalizePathFunction } from './path-resolve/resolvePath.js';
128
- export { normalizePath } from './path-resolve/resolvePath.js';
129
- export { osTempDir } from './path-resolve/resolvePath.js';
130
- export { relativePath } from './path-resolve/resolvePath.js';
134
+ // Identifiers
135
+ export type { ResolvePathFunction } from "./path-resolve/resolvePath.js";
136
+ export type { JoinPathFunction } from "./path-resolve/resolvePath.js";
137
+ export { resolvePath } from "./path-resolve/resolvePath.js";
138
+ export type { NormalizePathFunction } from "./path-resolve/resolvePath.js";
139
+ export { normalizePath } from "./path-resolve/resolvePath.js";
140
+ export { osTempDir } from "./path-resolve/resolvePath.js";
141
+ export { relativePath } from "./path-resolve/resolvePath.js";
131
142
  /* stream/blackHoleStream.ts */
132
- // Identifiers
133
- export { BlackHoleStream } from './stream/blackHoleStream.js';
143
+ // Identifiers
144
+ export { BlackHoleStream } from "./stream/blackHoleStream.js";
134
145
  /* stream/streamPromise.ts */
135
- // Identifiers
136
- export { streamPromise } from './stream/streamPromise.js';
137
- export { streamHasEnd } from './stream/streamPromise.js';
146
+ // Identifiers
147
+ export { streamPromise } from "./stream/streamPromise.js";
148
+ export { streamHasEnd } from "./stream/streamPromise.js";
138
149
  /* stream/collectingStream.ts */
139
- // Identifiers
140
- export { streamToBuffer } from './stream/collectingStream.js';
141
- export { RawCollectingStream } from './stream/collectingStream.js';
142
- export { CollectingStream } from './stream/collectingStream.js';
150
+ // Identifiers
151
+ export { streamToBuffer } from "./stream/collectingStream.js";
152
+ export { RawCollectingStream } from "./stream/collectingStream.js";
153
+ export { CollectingStream } from "./stream/collectingStream.js";
143
154
  /* stream/disposableStream.ts */
144
- // Identifiers
145
- export { disposableStream } from './stream/disposableStream.js';
155
+ // Identifiers
156
+ export { disposableStream } from "./stream/disposableStream.js";
146
157
  /* stream/drainStream.ts */
147
- // Identifiers
148
- export { drainStream } from './stream/drainStream.js';
158
+ // Identifiers
159
+ export { drainStream } from "./stream/drainStream.js";
149
160
  /* stream/loggerStream.ts */
150
- // Identifiers
151
- export type { LogFunction } from './stream/loggerStream.js';
152
- export { LoggerStream } from './stream/loggerStream.js';
153
- export { HexDumpLoggerStream } from './stream/loggerStream.js';
161
+ // Identifiers
162
+ export type { LogFunction } from "./stream/loggerStream.js";
163
+ export { LoggerStream } from "./stream/loggerStream.js";
164
+ export { HexDumpLoggerStream } from "./stream/loggerStream.js";
@@ -0,0 +1,66 @@
1
+ import { AppExit } from '@idlebox/common';
2
+
3
+ export class Exit extends AppExit {
4
+ constructor(code: number) {
5
+ super(`process exit with code ${code}`, code);
6
+ }
7
+ }
8
+
9
+ export class InterruptError extends Error {
10
+ constructor(public readonly signal: NodeJS.Signals) {
11
+ super(`interrupt by signal ${signal}`);
12
+ }
13
+ }
14
+
15
+ class ProxiedError extends Error {
16
+ declare cause: any;
17
+
18
+ constructor(prefix: string, original: unknown) {
19
+ super(`${prefix}: ${get_message(original)}`, { cause: original });
20
+ delete (this as any).stack;
21
+ }
22
+
23
+ override get stack(): string {
24
+ const cause: any = this.cause;
25
+ if (cause && 'stack' in cause) {
26
+ const stack = cause.stack;
27
+ if (typeof stack === 'string') {
28
+ return this.message + '\n' + removeFirstLine(cause.stack);
29
+ }
30
+ }
31
+ return `${this.message}\n no stack available`;
32
+ }
33
+ }
34
+
35
+ export class UnhandledRejection extends ProxiedError {
36
+ constructor(
37
+ reason: any,
38
+ public readonly promise: Promise<unknown>,
39
+ ) {
40
+ super('unhandled promise rejection', reason);
41
+ }
42
+ }
43
+
44
+ export class UncaughtException extends ProxiedError {
45
+ constructor(public readonly error: unknown) {
46
+ super('uncaught exception', error);
47
+ }
48
+ }
49
+
50
+ function get_message(reason: any): string {
51
+ if (reason instanceof Error) {
52
+ return reason.message;
53
+ }
54
+ if (reason && typeof reason === 'object' && 'message' in reason) {
55
+ return reason.message;
56
+ }
57
+ return String(reason);
58
+ }
59
+
60
+ function removeFirstLine(text: string) {
61
+ const index = text.indexOf('\n');
62
+ if (index !== -1) {
63
+ return text.slice(index + 1);
64
+ }
65
+ return text;
66
+ }
@@ -1,14 +1,24 @@
1
1
  /** biome-ignore-all lint/suspicious/noDebugger: debug file */
2
2
 
3
- import { AppExit, ensureDisposeGlobal, ensureGlobalObject, prettyPrintError } from '@idlebox/common';
3
+ import { AppExit, ensureDisposeGlobal, ensureGlobalObject, prettyPrintError, type MyCallback } from '@idlebox/common';
4
+ import assert from 'node:assert';
4
5
  import { createRequire, syncBuiltinESMExports } from 'node:module';
5
6
  import { basename } from 'node:path';
6
7
  import process from 'node:process';
8
+ import { Exit, InterruptError, UncaughtException, UnhandledRejection } from './internal-errors.js';
7
9
 
8
- const originalExit = process.exit;
10
+ const originalExit: (code?: number) => never = process.exit;
9
11
  const prefix = process.stderr.isTTY ? '' : `<${title()} ${process.pid}> `;
10
12
  const hasInspect = process.argv.some((arg) => arg.startsWith('--inspect=') || arg.startsWith('--inspect-brk=') || arg === '--inspect' || arg === '--inspect-brk');
11
13
 
14
+ let abnormalExitCode = 1;
15
+ export function setAbnormalExitCode(code: number) {
16
+ if (code < 1) {
17
+ throw new TypeError(`abnormal exit code must be greater than 0, got ${code}`);
18
+ }
19
+ abnormalExitCode = code;
20
+ }
21
+
12
22
  function title() {
13
23
  if (process.title && process.title !== 'node') {
14
24
  return process.title;
@@ -16,30 +26,100 @@ function title() {
16
26
  return basename(process.argv[1] || '') || 'node';
17
27
  }
18
28
 
19
- class Exit extends AppExit {
20
- constructor(code: number) {
21
- super(`process exit with code ${code}`, code);
22
- }
29
+ function getCurrentCode() {
30
+ return typeof process.exitCode === 'string' ? parseInt(process.exitCode) : process.exitCode || 0;
23
31
  }
24
32
 
25
- const shuttingDown = false;
33
+ let shuttingDown = false;
26
34
  export function shutdown(exitCode: number): never {
27
35
  if (hasInspect) debugger;
28
36
 
29
37
  if (exitCode) {
30
38
  process.exitCode = exitCode;
31
39
  }
32
- const code = typeof process.exitCode === 'string' ? parseInt(process.exitCode) : process.exitCode || 0;
33
40
 
34
- if (shuttingDown) {
35
- throw new Exit(code);
41
+ if (!shuttingDown) {
42
+ shuttingDown = true;
43
+ ensureDisposeGlobal().finally(() => {
44
+ originalExit(getCurrentCode());
45
+ });
36
46
  }
37
47
 
38
- ensureDisposeGlobal().finally(() => {
39
- originalExit(process.exitCode);
40
- });
48
+ throw new Exit(getCurrentCode());
49
+ }
50
+
51
+ const typed_error_handlers = new WeakMap<ErrorConstructor, MyCallback<[Error]>>();
52
+ const inherit_error_handlers = new Map<ErrorConstructor, MyCallback<[Error]>>();
53
+
54
+ type ErrorConstructor = new (...args: any[]) => Error;
55
+
56
+ export function registerNodejsGlobalTypedErrorHandlerWithInheritance(ErrorCls: ErrorConstructor, fn: MyCallback<[Error]>) {
57
+ if (typed_error_handlers.has(ErrorCls)) {
58
+ throw new ErrorCls(`conflict register of error type ${ErrorCls.name}`);
59
+ }
60
+ assert.notEqual(ErrorCls, Error, 'cannot register basic Error type');
61
+ inherit_error_handlers.set(ErrorCls, fn);
62
+ }
63
+ export function registerNodejsGlobalTypedErrorHandler(ErrorCls: ErrorConstructor, fn: MyCallback<[Error]>) {
64
+ if (typed_error_handlers.has(ErrorCls)) {
65
+ throw new ErrorCls(`conflict register of error type ${ErrorCls.name}`);
66
+ }
67
+ assert.notEqual(ErrorCls, Error, 'cannot register basic Error type');
68
+ typed_error_handlers.set(ErrorCls, fn);
69
+ }
70
+
71
+ function callErrorHandler(e: unknown) {
72
+ if (!(e instanceof Error)) {
73
+ prettyPrintError(`${prefix}catch unexpect object`, new Error(`error object is ${typeof e} ${e ? (e as any).constructor?.name : 'unknown'}`));
74
+ throw originalExit(abnormalExitCode);
75
+ }
76
+
77
+ try {
78
+ const catcher = typed_error_handlers.get(e.constructor as ErrorConstructor);
79
+ if (catcher) {
80
+ catcher(e);
81
+ return;
82
+ }
83
+ for (const [Cls, fn] of inherit_error_handlers) {
84
+ if (e instanceof Cls) {
85
+ fn(e);
86
+ return;
87
+ }
88
+ }
89
+ } catch (ee: any) {
90
+ prettyPrintError(`${prefix}error while handle error`, {
91
+ message: ee.message,
92
+ stack: ee.stack,
93
+ cause: e,
94
+ });
95
+ return;
96
+ }
97
+
98
+ if (e instanceof InterruptError) {
99
+ if (shuttingDown) {
100
+ console.error(`${prefix}Exiting immediately.`);
101
+ originalExit(1);
102
+ }
41
103
 
42
- throw new Exit(code);
104
+ shutdown(0);
105
+ }
106
+ if (e instanceof AppExit) {
107
+ ensureDisposeGlobal().finally(() => {
108
+ originalExit(getCurrentCode());
109
+ });
110
+ }
111
+ if (e instanceof UncaughtException) {
112
+ if (e.cause instanceof Error) {
113
+ prettyPrintError(`${prefix}Unhandled Rejection`, e.cause);
114
+ } else {
115
+ console.error(`${prefix}Unhandled Rejection / error type unknown:`, e.cause);
116
+ }
117
+ shutdown(abnormalExitCode);
118
+ }
119
+ if (e instanceof UncaughtException) {
120
+ prettyPrintError(`${prefix}Uncaught Exception`, e.cause);
121
+ shutdown(abnormalExitCode);
122
+ }
43
123
  }
44
124
 
45
125
  /**
@@ -51,37 +131,25 @@ export function registerNodejsExitHandler() {
51
131
  function _real_register() {
52
132
  process.on('SIGINT', () => {
53
133
  console.error(`\n${prefix}Received SIGINT. Exiting gracefully...`);
54
-
55
- if (shuttingDown) {
56
- console.error(`Exiting immediately.`);
57
- originalExit(1);
58
- }
59
-
60
- shutdown(0);
134
+ callErrorHandler(new InterruptError('SIGINT'));
61
135
  });
62
136
 
63
137
  process.on('SIGTERM', () => {
64
138
  console.error(`${prefix}Received SIGTERM. Exiting gracefully...`);
65
- shutdown(0);
139
+ callErrorHandler(new InterruptError('SIGTERM'));
66
140
  });
67
141
 
68
142
  process.on('beforeExit', (code) => {
69
- console.error(`${prefix}Process beforeExit with code: ${code}`);
143
+ // empty handler prevent real exit
70
144
  shutdown(code);
71
145
  });
72
146
 
73
- process.on('unhandledRejection', (reason, _promise) => {
74
- if (hasInspect) debugger;
75
-
76
- if (reason instanceof Error) {
77
- if (reason instanceof AppExit) {
78
- return;
79
- }
80
- prettyPrintError(`${prefix}Unhandled Rejection`, reason);
81
- } else {
82
- console.error(`${prefix}Unhandled Rejection / error type unknown:`, reason);
147
+ process.on('unhandledRejection', (reason, promise) => {
148
+ if (reason instanceof AppExit) {
149
+ return;
83
150
  }
84
- shutdown(1);
151
+ if (hasInspect) debugger;
152
+ callErrorHandler(new UnhandledRejection(reason, promise));
85
153
  });
86
154
 
87
155
  const processMdl = createRequire(import.meta.url)('node:process');
@@ -92,11 +160,9 @@ function _real_register() {
92
160
  if (error instanceof AppExit) {
93
161
  return;
94
162
  }
95
-
96
163
  if (hasInspect) debugger;
97
164
 
98
- prettyPrintError(`${prefix}Uncaught Exception`, error);
99
- shutdown(1);
165
+ callErrorHandler(new UncaughtException(error));
100
166
  }
101
167
 
102
168
  if (process.hasUncaughtExceptionCaptureCallback()) {
@@ -1,80 +0,0 @@
1
- export type { AsyncMainFunction } from "./asyncLoad.js";
2
- export { executeMainFunction } from "./asyncLoad.js";
3
- export { checkChildProcessResult } from "./child_process/error.js";
4
- export type { ICommand } from "./child_process/execa.js";
5
- export { spawnWithoutOutputSync } from "./child_process/execa.js";
6
- export { spawnWithoutOutput } from "./child_process/execa.js";
7
- export { spawnGetOutputSync } from "./child_process/execa.js";
8
- export { spawnGetOutput } from "./child_process/execa.js";
9
- export { spawnGetEverything } from "./child_process/execa.js";
10
- export { printLine } from "./cli-io/output.js";
11
- export type { ISpawnOptions } from "./child_process/lateError.js";
12
- export type { ExecaReturnValue } from "./child_process/lateError.js";
13
- export { execLazyError } from "./child_process/lateError.js";
14
- export { LinuxError } from "./error/linux.js";
15
- export type { OpenSSLException } from "./error/types.js";
16
- export { isModuleResolutionError } from "./error/types.js";
17
- export { isNotExistsError } from "./error/types.js";
18
- export { isExistsError } from "./error/types.js";
19
- export { isTypeError } from "./error/types.js";
20
- export { isFileTypeError } from "./error/types.js";
21
- export { isNodeError } from "./error/types.js";
22
- export * from "@idlebox/node-error-codes";
23
- export { existsSync } from "./fs/exists.js";
24
- export { exists } from "./fs/exists.js";
25
- export { readFileIfExists } from "./fs/exists.js";
26
- export type { IEnvironmentResult } from "./environment/getEnvironment.js";
27
- export { getEnvironment } from "./environment/getEnvironment.js";
28
- export { deleteEnvironment } from "./environment/getEnvironment.js";
29
- export { cleanupEnvironment } from "./environment/getEnvironment.js";
30
- export { PATH_SEPARATOR } from "./environment/pathEnvironment.js";
31
- export { PathEnvironment } from "./environment/pathEnvironment.js";
32
- export { findBinary } from "./environment/findBinary.js";
33
- export { spawnRecreateEventHandlers } from "./child_process/respawn.js";
34
- export { trySpawnInScope } from "./child_process/respawn.js";
35
- export { respawnInScope } from "./child_process/respawn.js";
36
- export { md5 } from "./crypto/md5.js";
37
- export { sha256 } from "./crypto/sha256.js";
38
- export { getNpmConfigValue } from "./environment/npmConfig.js";
39
- export { dumpEventEmitterEmit } from "./events/dumpEventEmitter.js";
40
- export { commandInPath } from "./fs/commandExists.js";
41
- export { commandInPathSync } from "./fs/commandExists.js";
42
- export { emptyDir } from "./fs/emptyDir.js";
43
- export { ensureDirExists } from "./fs/ensureDir.js";
44
- export { ensureParentExists } from "./fs/ensureDir.js";
45
- export { createTempFolder } from "./fs/tempFolder.js";
46
- export { writeFileIfChangeSync } from "./fs/weiteChanged.js";
47
- export { writeFileIfChange } from "./fs/weiteChanged.js";
48
- export { shutdown } from "./lifecycle/register.js";
49
- export { registerNodejsExitHandler } from "./lifecycle/register.js";
50
- export { die } from "./lifecycle/register.js";
51
- export { WrappedTerminalConsole } from "./log/terminal.js";
52
- export type { IFindOptions } from "./path-resolve/findUp.js";
53
- export { findUpUntil } from "./path-resolve/findUp.js";
54
- export { findUp } from "./path-resolve/findUp.js";
55
- export { findUpUntilSync } from "./path-resolve/findUp.js";
56
- export { findUpSync } from "./path-resolve/findUp.js";
57
- export { findPackageRoot } from "./path-resolve/findPackageRoot.js";
58
- export { getAllPathUpToRoot } from "./path-resolve/getAllUp.js";
59
- export { lrelative } from "./path-resolve/lrelative.js";
60
- export { nodeResolvePathArray } from "./path-resolve/nodeResolvePathArray.js";
61
- export type { ResolvePathFunction } from "./path-resolve/resolvePath.js";
62
- export type { JoinPathFunction } from "./path-resolve/resolvePath.js";
63
- export { resolvePath } from "./path-resolve/resolvePath.js";
64
- export type { NormalizePathFunction } from "./path-resolve/resolvePath.js";
65
- export { normalizePath } from "./path-resolve/resolvePath.js";
66
- export { osTempDir } from "./path-resolve/resolvePath.js";
67
- export { relativePath } from "./path-resolve/resolvePath.js";
68
- export { BlackHoleStream } from "./stream/blackHoleStream.js";
69
- export { streamPromise } from "./stream/streamPromise.js";
70
- export { streamHasEnd } from "./stream/streamPromise.js";
71
- export { streamToBuffer } from "./stream/collectingStream.js";
72
- export { RawCollectingStream } from "./stream/collectingStream.js";
73
- export { CollectingStream } from "./stream/collectingStream.js";
74
- export { disposableStream } from "./stream/disposableStream.js";
75
- export { drainStream } from "./stream/drainStream.js";
76
- export type { LogFunction } from "./stream/loggerStream.js";
77
- export { LoggerStream } from "./stream/loggerStream.js";
78
- export { HexDumpLoggerStream } from "./stream/loggerStream.js";
79
- export * from "@idlebox/node-error-codes";
80
- //# sourceMappingURL=autoindex.generated.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"autoindex.generated.d.ts","sourceRoot":"","sources":["../src/autoindex.generated.ts"],"names":[],"mappings":"AAMC,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAGnE,YAAY,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MA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