@idlebox/node 1.4.10 → 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,75 +1,155 @@
1
- import { AppExit, ensureDisposeGlobal, globalSingletonStrong, prettyPrintError } from '@idlebox/common';
1
+ /** biome-ignore-all lint/suspicious/noDebugger: debug file */
2
+
3
+ import { AppExit, ensureDisposeGlobal, ensureGlobalObject, prettyPrintError, type MyCallback } from '@idlebox/common';
4
+ import assert from 'node:assert';
2
5
  import { createRequire, syncBuiltinESMExports } from 'node:module';
6
+ import { basename } from 'node:path';
3
7
  import process from 'node:process';
8
+ import { Exit, InterruptError, UncaughtException, UnhandledRejection } from './internal-errors.js';
9
+
10
+ const originalExit: (code?: number) => never = process.exit;
11
+ const prefix = process.stderr.isTTY ? '' : `<${title()} ${process.pid}> `;
12
+ const hasInspect = process.argv.some((arg) => arg.startsWith('--inspect=') || arg.startsWith('--inspect-brk=') || arg === '--inspect' || arg === '--inspect-brk');
4
13
 
5
- const originalExit = process.exit;
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
+ }
6
21
 
7
- class Exit extends AppExit {
8
- constructor(code: number) {
9
- super(`process exit with code ${code}`, code);
22
+ function title() {
23
+ if (process.title && process.title !== 'node') {
24
+ return process.title;
10
25
  }
26
+ return basename(process.argv[1] || '') || 'node';
27
+ }
28
+
29
+ function getCurrentCode() {
30
+ return typeof process.exitCode === 'string' ? parseInt(process.exitCode) : process.exitCode || 0;
11
31
  }
12
32
 
13
- const shuttingDown = false;
33
+ let shuttingDown = false;
14
34
  export function shutdown(exitCode: number): never {
15
- debugger;
35
+ if (hasInspect) debugger;
16
36
 
17
37
  if (exitCode) {
18
38
  process.exitCode = exitCode;
19
39
  }
20
- const code = typeof process.exitCode === 'string' ? parseInt(process.exitCode) : process.exitCode || 0;
21
40
 
22
- if (shuttingDown) {
23
- throw new Exit(code);
41
+ if (!shuttingDown) {
42
+ shuttingDown = true;
43
+ ensureDisposeGlobal().finally(() => {
44
+ originalExit(getCurrentCode());
45
+ });
24
46
  }
25
47
 
26
- ensureDisposeGlobal().finally(() => {
27
- originalExit(process.exitCode);
28
- });
48
+ throw new Exit(getCurrentCode());
49
+ }
29
50
 
30
- throw new Exit(code);
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);
31
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
+ }
32
103
 
33
- const exitHandler = Symbol('exithandler/registed');
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
+ }
123
+ }
34
124
 
35
125
  /**
36
126
  * 注册nodejs退出处理器
37
127
  */
38
128
  export function registerNodejsExitHandler() {
39
- globalSingletonStrong(exitHandler, _real_register);
129
+ ensureGlobalObject('exithandler/register', _real_register);
40
130
  }
41
131
  function _real_register() {
42
132
  process.on('SIGINT', () => {
43
- console.log('\nReceived SIGINT. Exiting gracefully...');
44
-
45
- if (shuttingDown) {
46
- console.error('Exiting immediately.');
47
- originalExit(1);
48
- }
49
-
50
- shutdown(0);
133
+ console.error(`\n${prefix}Received SIGINT. Exiting gracefully...`);
134
+ callErrorHandler(new InterruptError('SIGINT'));
51
135
  });
52
136
 
53
137
  process.on('SIGTERM', () => {
54
- console.log('Received SIGTERM. Exiting gracefully...');
55
- shutdown(0);
138
+ console.error(`${prefix}Received SIGTERM. Exiting gracefully...`);
139
+ callErrorHandler(new InterruptError('SIGTERM'));
56
140
  });
57
141
 
58
142
  process.on('beforeExit', (code) => {
59
- console.log(`Process beforeExit with code: ${code}`);
143
+ // empty handler prevent real exit
60
144
  shutdown(code);
61
145
  });
62
146
 
63
- process.on('unhandledRejection', (reason, _promise) => {
64
- if (reason instanceof Error) {
65
- if (reason instanceof AppExit) {
66
- return;
67
- }
68
- prettyPrintError('Unhandled Rejection', reason);
69
- } else {
70
- console.error('Unhandled Rejection / error type unknown:', reason);
147
+ process.on('unhandledRejection', (reason, promise) => {
148
+ if (reason instanceof AppExit) {
149
+ return;
71
150
  }
72
- shutdown(1);
151
+ if (hasInspect) debugger;
152
+ callErrorHandler(new UnhandledRejection(reason, promise));
73
153
  });
74
154
 
75
155
  const processMdl = createRequire(import.meta.url)('node:process');
@@ -80,13 +160,14 @@ function _real_register() {
80
160
  if (error instanceof AppExit) {
81
161
  return;
82
162
  }
83
- prettyPrintError('Uncaught Exception', error);
84
- shutdown(1);
163
+ if (hasInspect) debugger;
164
+
165
+ callErrorHandler(new UncaughtException(error));
85
166
  }
86
167
 
87
168
  if (process.hasUncaughtExceptionCaptureCallback()) {
88
169
  process.on('uncaughtException', uncaughtException);
89
- throw new Error('[process uncaught exception capture] callback already registered by other module');
170
+ throw new Error(`${prefix} [uncaught exception capture] callback already registered by other module`);
90
171
  }
91
172
  process.setUncaughtExceptionCaptureCallback(uncaughtException);
92
173
 
@@ -97,6 +178,7 @@ function _real_register() {
97
178
  * @deprecated 仅用于测试
98
179
  */
99
180
  export function die(message: string): never {
100
- console.error(message);
181
+ debugger;
182
+ console.error(`${prefix}DIE!`, message);
101
183
  shutdown(1);
102
184
  }
@@ -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