@tapjs/processinfo 1.0.3 → 1.0.5

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/index.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  /// <reference types="node" />
2
2
  import {
3
- spawn,
4
- spawnSync,
5
- exec,
6
- execSync,
7
- execFile,
8
- execFileSync,
3
+ ChildProcess,
4
+ ExecException,
5
+ ExecFileOptions,
6
+ ExecFileSyncOptions,
7
+ ExecOptions,
8
+ ExecSyncOptions,
9
+ SpawnOptions,
10
+ SpawnSyncOptions,
11
+ SpawnSyncReturns,
9
12
  } from 'node:child_process'
10
13
 
11
14
  declare interface ProcessInfoOptions {
@@ -21,6 +24,52 @@ declare class ProcessInfoNode {
21
24
  link(db: ProcessInfo): void
22
25
  }
23
26
 
27
+ declare interface ProcessInfoSpawnOptions extends SpawnOptions {
28
+ externalID?: string
29
+ }
30
+
31
+ declare interface ProcessInfoSpawnSyncOptions extends SpawnSyncOptions {
32
+ externalID?: string
33
+ }
34
+ declare interface ProcessInfoSpawnSyncOptionsWithStringEncoding
35
+ extends ProcessInfoSpawnSyncOptions {
36
+ encoding: BufferEncoding
37
+ }
38
+ interface ProcessInfoSpawnSyncOptionsWithBufferEncoding
39
+ extends ProcessInfoSpawnSyncOptions {
40
+ encoding?: 'buffer' | null | undefined
41
+ }
42
+
43
+ declare interface ProcessInfoExecSyncOptions extends ExecSyncOptions {
44
+ externalID?: string
45
+ }
46
+ declare interface ProcessInfoExecSyncOptionsWithStringEncoding
47
+ extends ProcessInfoExecSyncOptions {
48
+ encoding: BufferEncoding
49
+ }
50
+ declare interface ProcessInfoExecSyncOptionsWithBufferEncoding
51
+ extends ProcessInfoExecSyncOptions {
52
+ encoding?: 'buffer' | null | undefined
53
+ }
54
+
55
+ declare interface ProcessInfoExecOptions extends ExecOptions {
56
+ externalID?: string
57
+ }
58
+ declare interface ProcessInfoExecFileSyncOptions extends ExecFileSyncOptions {
59
+ externalID?: string
60
+ }
61
+ declare interface ProcessInfoExecFileSyncOptionsWithStringEncoding
62
+ extends ProcessInfoExecFileSyncOptions {
63
+ encoding: BufferEncoding
64
+ }
65
+ declare interface ProcessInfoExecFileSyncOptionsWithBufferEncoding
66
+ extends ProcessInfoExecFileSyncOptions {
67
+ encoding?: 'buffer' | null | undefined
68
+ }
69
+ declare interface ProcessInfoExecFileOptions extends ExecFileOptions {
70
+ externalID?: string
71
+ }
72
+
24
73
  declare class ProcessInfo {
25
74
  public dir: string
26
75
  public exclude: RegExp
@@ -44,12 +93,104 @@ declare class ProcessInfo {
44
93
 
45
94
  static get Node(): typeof ProcessInfoNode
46
95
  static get ProcessInfo(): typeof ProcessInfo
47
- static get spawn(): typeof spawn
48
- static get spawnSync(): typeof spawnSync
49
- static get exec(): typeof exec
50
- static get execSync(): typeof execSync
51
- static get execFile(): typeof execFile
52
- static get execFileSync(): typeof execFileSync
96
+
97
+ static spawn(
98
+ cmd: string,
99
+ args: string[],
100
+ options: ProcessInfoSpawnOptions
101
+ ): ChildProcess
102
+
103
+ static spawnSync(cmd: string): SpawnSyncReturns<Buffer>
104
+ static spawnSync(
105
+ cmd: string,
106
+ options: ProcessInfoSpawnSyncOptionsWithStringEncoding
107
+ ): SpawnSyncReturns<string>
108
+ static spawnSync(
109
+ cmd: string,
110
+ options: ProcessInfoSpawnSyncOptionsWithBufferEncoding
111
+ ): SpawnSyncReturns<Buffer>
112
+ static spawnSync(
113
+ cmd: string,
114
+ options?: ProcessInfoSpawnSyncOptions
115
+ ): SpawnSyncReturns<string | Buffer>
116
+ static spawnSync(
117
+ cmd: string,
118
+ args: readonly string[]
119
+ ): SpawnSyncReturns<Buffer>
120
+ static spawnSync(
121
+ cmd: string,
122
+ args: readonly string[],
123
+ options: ProcessInfoSpawnSyncOptionsWithStringEncoding
124
+ ): SpawnSyncReturns<string>
125
+ static spawnSync(
126
+ cmd: string,
127
+ args: readonly string[],
128
+ options: ProcessInfoSpawnSyncOptionsWithBufferEncoding
129
+ ): SpawnSyncReturns<Buffer>
130
+ static spawnSync(
131
+ cmd: string,
132
+ args?: readonly string[],
133
+ options?: ProcessInfoSpawnSyncOptions
134
+ ): SpawnSyncReturns<string | Buffer>
135
+
136
+ static exec(
137
+ cmd: string,
138
+ options: ProcessInfoExecOptions,
139
+ callback?: (
140
+ error: ExecException | null,
141
+ stdout: Buffer,
142
+ stderr: Buffer
143
+ ) => void
144
+ ): ChildProcess
145
+
146
+ static execSync(
147
+ cmd: string,
148
+ options: ProcessInfoExecSyncOptionsWithStringEncoding
149
+ ): string
150
+ static execSync(
151
+ cmd: string,
152
+ options: ProcessInfoExecSyncOptionsWithBufferEncoding
153
+ ): Buffer
154
+ static execSync(
155
+ cmd: string,
156
+ options?: ProcessInfoExecSyncOptions
157
+ ): string | Buffer
158
+
159
+ static execFile(
160
+ cmd: string,
161
+ args: string[],
162
+ options: ProcessInfoExecFileOptions
163
+ ): ChildProcess
164
+
165
+ static execFileSync(file: string): Buffer
166
+ static execFileSync(
167
+ file: string,
168
+ options: ProcessInfoExecFileSyncOptionsWithStringEncoding
169
+ ): string
170
+ static execFileSync(
171
+ file: string,
172
+ options: ProcessInfoExecFileSyncOptionsWithBufferEncoding
173
+ ): Buffer
174
+ static execFileSync(
175
+ file: string,
176
+ options?: ProcessInfoExecFileSyncOptions
177
+ ): string | Buffer
178
+ static execFileSync(file: string, args: readonly string[]): Buffer
179
+ static execFileSync(
180
+ file: string,
181
+ args: readonly string[],
182
+ options: ProcessInfoExecFileSyncOptionsWithStringEncoding
183
+ ): string
184
+ static execFileSync(
185
+ file: string,
186
+ args: readonly string[],
187
+ options: ProcessInfoExecFileSyncOptionsWithBufferEncoding
188
+ ): Buffer
189
+ static execFileSync(
190
+ file: string,
191
+ args?: readonly string[],
192
+ options?: ProcessInfoExecFileSyncOptions
193
+ ): string | Buffer
53
194
  }
54
195
 
55
196
  export = ProcessInfo
@@ -12,10 +12,28 @@ const k = '_TAPJS_PROCESSINFO_EXCLUDE_'
12
12
 
13
13
  module.exports = {
14
14
  spawn(cmd, args, options) {
15
+ if (
16
+ args &&
17
+ typeof args === 'object' &&
18
+ !Array.isArray(args) &&
19
+ options === undefined
20
+ ) {
21
+ options = args
22
+ args = []
23
+ }
15
24
  return spawn(cmd, args, spawnOpts(options, getExclude(k)))
16
25
  },
17
26
 
18
27
  spawnSync(cmd, args, options) {
28
+ if (
29
+ args &&
30
+ typeof args === 'object' &&
31
+ !Array.isArray(args) &&
32
+ options === undefined
33
+ ) {
34
+ options = args
35
+ args = []
36
+ }
19
37
  return spawnSync(cmd, args, spawnOpts(options, getExclude(k)))
20
38
  },
21
39
 
package/lib/esm.mjs CHANGED
@@ -7,15 +7,18 @@ import './cjs.cjs'
7
7
  const processInfo = getProcessInfo()
8
8
  const exclude = getExclude('_TAPJS_PROCESSINFO_EXCLUDE_')
9
9
 
10
- const others = Promise.all(
10
+ let others = Promise.all(
11
11
  [...new URL(import.meta.url).searchParams.keys()].map(s =>
12
12
  import(s).catch(() => ({}))
13
13
  )
14
- )
15
- const hasLoad = (async () =>
14
+ ).then(o => others = o)
15
+
16
+ let hasLoad = (async () =>
16
17
  (await others).filter(loader => typeof loader.load === 'function'))()
17
- const hasResolve = (async () =>
18
+ .then(has => hasLoad = has)
19
+ let hasResolve = (async () =>
18
20
  (await others).filter(loader => typeof loader.resolve === 'function'))()
21
+ .then(has => hasResolve = has)
19
22
 
20
23
  const myLoad = defaultFn => async (url, context) => {
21
24
  if (/^file:/.test(url)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapjs/processinfo",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "main": "lib/index.cjs",
5
5
  "files": [
6
6
  "index.d.ts",
@@ -36,7 +36,6 @@
36
36
  "dependencies": {
37
37
  "pirates": "^4.0.5",
38
38
  "process-on-spawn": "^1.0.0",
39
- "tap": "^16.3.0",
40
39
  "uuid": "^8.3.2"
41
40
  },
42
41
  "engines": {
@@ -48,7 +47,8 @@
48
47
  "@types/node": "^18.11.9",
49
48
  "diff": "^5.0.0",
50
49
  "eslint-config-prettier": "^8.5.0",
51
- "prettier": "^2.6.2"
50
+ "prettier": "^2.6.2",
51
+ "tap": "^16.3.0"
52
52
  },
53
53
  "repository": "https://github.com/tapjs/processinfo"
54
54
  }