@idlebox/node 1.4.9 → 1.4.10

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,151 @@
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
97
  /* 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";
98
+ // Identifiers
99
+ export { shutdown } from './lifecycle/register.js';
100
+ export { registerNodejsExitHandler } from './lifecycle/register.js';
101
+ export { die } from './lifecycle/register.js';
102
102
  /* log/terminal.ts */
103
- // Identifiers
104
- export { WrappedTerminalConsole } from "./log/terminal.js";
103
+ // Identifiers
104
+ export { WrappedTerminalConsole } from './log/terminal.js';
105
105
  /* 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";
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';
110
110
  /* path-resolve/findPackageRoot.ts */
111
- // Identifiers
112
- export { findPackageRoot } from "./path-resolve/findPackageRoot.js";
111
+ // Identifiers
112
+ export { findPackageRoot } from './path-resolve/findPackageRoot.js';
113
113
  /* path-resolve/getAllUp.ts */
114
- // Identifiers
115
- export { getAllPathUpToRoot } from "./path-resolve/getAllUp.js";
114
+ // Identifiers
115
+ export { getAllPathUpToRoot } from './path-resolve/getAllUp.js';
116
116
  /* path-resolve/lrelative.ts */
117
- // Identifiers
118
- export { lrelative } from "./path-resolve/lrelative.js";
117
+ // Identifiers
118
+ export { lrelative } from './path-resolve/lrelative.js';
119
119
  /* path-resolve/nodeResolvePathArray.ts */
120
- // Identifiers
121
- export { nodeResolvePathArray } from "./path-resolve/nodeResolvePathArray.js";
120
+ // Identifiers
121
+ export { nodeResolvePathArray } from './path-resolve/nodeResolvePathArray.js';
122
122
  /* 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";
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';
131
131
  /* stream/blackHoleStream.ts */
132
- // Identifiers
133
- export { BlackHoleStream } from "./stream/blackHoleStream.js";
132
+ // Identifiers
133
+ export { BlackHoleStream } from './stream/blackHoleStream.js';
134
134
  /* stream/streamPromise.ts */
135
- // Identifiers
136
- export { streamPromise } from "./stream/streamPromise.js";
137
- export { streamHasEnd } from "./stream/streamPromise.js";
135
+ // Identifiers
136
+ export { streamPromise } from './stream/streamPromise.js';
137
+ export { streamHasEnd } from './stream/streamPromise.js';
138
138
  /* 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";
139
+ // Identifiers
140
+ export { streamToBuffer } from './stream/collectingStream.js';
141
+ export { RawCollectingStream } from './stream/collectingStream.js';
142
+ export { CollectingStream } from './stream/collectingStream.js';
143
143
  /* stream/disposableStream.ts */
144
- // Identifiers
145
- export { disposableStream } from "./stream/disposableStream.js";
144
+ // Identifiers
145
+ export { disposableStream } from './stream/disposableStream.js';
146
146
  /* stream/drainStream.ts */
147
- // Identifiers
148
- export { drainStream } from "./stream/drainStream.js";
147
+ // Identifiers
148
+ export { drainStream } from './stream/drainStream.js';
149
149
  /* 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";
150
+ // Identifiers
151
+ export type { LogFunction } from './stream/loggerStream.js';
152
+ export { LoggerStream } from './stream/loggerStream.js';
153
+ export { HexDumpLoggerStream } from './stream/loggerStream.js';
@@ -2,10 +2,7 @@ import { execa, type Options as ExecaOptions, type Result } from 'execa';
2
2
  import { printLine } from '../cli-io/output.js';
3
3
  import { checkChildProcessResult } from './error.js';
4
4
 
5
- export type ISpawnOptions = Omit<
6
- ExecaOptions,
7
- 'lines' | 'reject' | 'stdio' | 'encoding' | 'all' | 'stderr' | 'verbose'
8
- > & {
5
+ export type ISpawnOptions = Omit<ExecaOptions, 'lines' | 'reject' | 'stdio' | 'encoding' | 'all' | 'stderr' | 'verbose'> & {
9
6
  verbose?: boolean;
10
7
  };
11
8
  type ISpawnConst = {
@@ -17,9 +14,7 @@ type ISpawnConst = {
17
14
 
18
15
  type ConvStdout<T extends ISpawnOptions> = T['stdout'] extends 'inherit' ? Omit<T, 'stdout'> & { stdout: 'pipe' } : T;
19
16
 
20
- export type ExecaReturnValue<options extends ISpawnOptions> = Result<
21
- ConvStdout<Omit<options, 'verbose'>> & ISpawnConst
22
- >;
17
+ export type ExecaReturnValue<options extends ISpawnOptions> = Result<ConvStdout<Omit<options, 'verbose'>> & ISpawnConst>;
23
18
 
24
19
  type NoStdio = Omit<ISpawnOptions, 'stdio'> & { stdio?: never };
25
20
 
@@ -27,11 +22,7 @@ type NoStdio = Omit<ISpawnOptions, 'stdio'> & { stdio?: never };
27
22
  * 运行命令,如果出错,则输出缓冲的stderr(如果stdout是inherit,也同时输出stdout)
28
23
  * 如果程序正常结束,则程序向stderr输出的内容直接丢弃(如果stdout是inherit,也同时丢弃)
29
24
  */
30
- export function execLazyError<T extends NoStdio = NoStdio>(
31
- cmd: string,
32
- args: string[],
33
- spawnOptions: T
34
- ): Promise<ExecaReturnValue<T>> {
25
+ export function execLazyError<T extends NoStdio = NoStdio>(cmd: string, args: string[], spawnOptions: T): Promise<ExecaReturnValue<T>> {
35
26
  let all = false;
36
27
  let { stdout, verbose, ...others } = spawnOptions;
37
28
 
@@ -113,11 +113,7 @@ function execLinux(cmds: string[]): never {
113
113
  process.execve!(unshare, args);
114
114
  console.error('[Linux] execve failed.');
115
115
  } catch (err: any) {
116
- if (
117
- err.code === 'MODULE_NOT_FOUND' ||
118
- err.code === 'ERR_MODULE_NOT_FOUND' ||
119
- err.code === 'UNDECLARED_DEPENDENCY'
120
- ) {
116
+ if (err.code === 'MODULE_NOT_FOUND' || err.code === 'ERR_MODULE_NOT_FOUND' || err.code === 'UNDECLARED_DEPENDENCY') {
121
117
  spawnSimulate(unshare, args);
122
118
  } else {
123
119
  console.error('[Linux] <%s> execve failed:', err.code, err);
@@ -15,9 +15,7 @@ export interface OpenSSLException extends Error {
15
15
  * MODULE_NOT_FOUND: require() not found
16
16
  * ERR_MODULE_NOT_FOUND: import() not found
17
17
  */
18
- export function isModuleResolutionError(
19
- ex: unknown,
20
- ): ex is NodeException<NodeError.MODULE_NOT_FOUND | NodeError.ERR_MODULE_NOT_FOUND> {
18
+ export function isModuleResolutionError(ex: unknown): ex is NodeException<NodeError.MODULE_NOT_FOUND | NodeError.ERR_MODULE_NOT_FOUND> {
21
19
  return isNodeError(ex) && (ex.code === NodeError.MODULE_NOT_FOUND || ex.code === NodeError.ERR_MODULE_NOT_FOUND);
22
20
  }
23
21
 
@@ -10,8 +10,10 @@ class Exit extends AppExit {
10
10
  }
11
11
  }
12
12
 
13
- let shuttingDown = false;
13
+ const shuttingDown = false;
14
14
  export function shutdown(exitCode: number): never {
15
+ debugger;
16
+
15
17
  if (exitCode) {
16
18
  process.exitCode = exitCode;
17
19
  }
@@ -53,7 +55,10 @@ function _real_register() {
53
55
  shutdown(0);
54
56
  });
55
57
 
56
- process.on('beforeExit', shutdown);
58
+ process.on('beforeExit', (code) => {
59
+ console.log(`Process beforeExit with code: ${code}`);
60
+ shutdown(code);
61
+ });
57
62
 
58
63
  process.on('unhandledRejection', (reason, _promise) => {
59
64
  if (reason instanceof Error) {
@@ -7,8 +7,8 @@ export function lrelative(from: string, to: string) {
7
7
  if (!isAbsolute(to)) {
8
8
  throw new Error(`lrelative: to is not absolute: ${to}`);
9
9
  }
10
- const fa = from.split(/[\/\\]/g).filter((e) => e);
11
- const ta = to.split(/[\/\\]/g).filter((e) => e);
10
+ const fa = from.split(/[/\\]/g).filter((e) => e);
11
+ const ta = to.split(/[/\\]/g).filter((e) => e);
12
12
  const f = ta.pop();
13
13
  while (fa[0] === ta[0]) {
14
14
  fa.shift();
@@ -7,7 +7,7 @@ export class LoggerStream extends Transform {
7
7
 
8
8
  constructor(
9
9
  private readonly logFn: LogFunction,
10
- prefix?: string
10
+ prefix?: string,
11
11
  ) {
12
12
  super();
13
13
  this.prefix = prefix ? `${prefix} %s` : '%s';
@@ -39,7 +39,7 @@ export class HexDumpLoggerStream extends Transform {
39
39
 
40
40
  constructor(
41
41
  private readonly logFn: LogFunction,
42
- prefix?: string
42
+ prefix?: string,
43
43
  ) {
44
44
  super();
45
45
  this.prefix = prefix ? `${prefix} ` : '';