@tapjs/processinfo 1.0.4 → 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 +111 -18
- package/lib/child_process.cjs +18 -0
- package/lib/esm.mjs +7 -4
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import {
|
|
3
3
|
ChildProcess,
|
|
4
|
+
ExecException,
|
|
4
5
|
ExecFileOptions,
|
|
5
6
|
ExecFileSyncOptions,
|
|
6
7
|
ExecOptions,
|
|
7
8
|
ExecSyncOptions,
|
|
8
9
|
SpawnOptions,
|
|
9
10
|
SpawnSyncOptions,
|
|
11
|
+
SpawnSyncReturns,
|
|
10
12
|
} from 'node:child_process'
|
|
11
13
|
|
|
12
14
|
declare interface ProcessInfoOptions {
|
|
@@ -25,18 +27,45 @@ declare class ProcessInfoNode {
|
|
|
25
27
|
declare interface ProcessInfoSpawnOptions extends SpawnOptions {
|
|
26
28
|
externalID?: string
|
|
27
29
|
}
|
|
30
|
+
|
|
28
31
|
declare interface ProcessInfoSpawnSyncOptions extends SpawnSyncOptions {
|
|
29
32
|
externalID?: string
|
|
30
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
|
+
|
|
31
43
|
declare interface ProcessInfoExecSyncOptions extends ExecSyncOptions {
|
|
32
44
|
externalID?: string
|
|
33
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
|
+
|
|
34
55
|
declare interface ProcessInfoExecOptions extends ExecOptions {
|
|
35
56
|
externalID?: string
|
|
36
57
|
}
|
|
37
58
|
declare interface ProcessInfoExecFileSyncOptions extends ExecFileSyncOptions {
|
|
38
59
|
externalID?: string
|
|
39
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
|
+
}
|
|
40
69
|
declare interface ProcessInfoExecFileOptions extends ExecFileOptions {
|
|
41
70
|
externalID?: string
|
|
42
71
|
}
|
|
@@ -65,17 +94,46 @@ declare class ProcessInfo {
|
|
|
65
94
|
static get Node(): typeof ProcessInfoNode
|
|
66
95
|
static get ProcessInfo(): typeof ProcessInfo
|
|
67
96
|
|
|
68
|
-
static
|
|
97
|
+
static spawn(
|
|
69
98
|
cmd: string,
|
|
70
99
|
args: string[],
|
|
71
100
|
options: ProcessInfoSpawnOptions
|
|
72
|
-
)
|
|
73
|
-
|
|
101
|
+
): ChildProcess
|
|
102
|
+
|
|
103
|
+
static spawnSync(cmd: string): SpawnSyncReturns<Buffer>
|
|
104
|
+
static spawnSync(
|
|
74
105
|
cmd: string,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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(
|
|
79
137
|
cmd: string,
|
|
80
138
|
options: ProcessInfoExecOptions,
|
|
81
139
|
callback?: (
|
|
@@ -83,21 +141,56 @@ declare class ProcessInfo {
|
|
|
83
141
|
stdout: Buffer,
|
|
84
142
|
stderr: Buffer
|
|
85
143
|
) => void
|
|
86
|
-
)
|
|
87
|
-
|
|
144
|
+
): ChildProcess
|
|
145
|
+
|
|
146
|
+
static execSync(
|
|
88
147
|
cmd: string,
|
|
89
|
-
options:
|
|
90
|
-
)
|
|
91
|
-
static
|
|
148
|
+
options: ProcessInfoExecSyncOptionsWithStringEncoding
|
|
149
|
+
): string
|
|
150
|
+
static execSync(
|
|
92
151
|
cmd: string,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
152
|
+
options: ProcessInfoExecSyncOptionsWithBufferEncoding
|
|
153
|
+
): Buffer
|
|
154
|
+
static execSync(
|
|
155
|
+
cmd: string,
|
|
156
|
+
options?: ProcessInfoExecSyncOptions
|
|
157
|
+
): string | Buffer
|
|
158
|
+
|
|
159
|
+
static execFile(
|
|
97
160
|
cmd: string,
|
|
98
161
|
args: string[],
|
|
99
|
-
options:
|
|
100
|
-
)
|
|
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
|
|
101
194
|
}
|
|
102
195
|
|
|
103
196
|
export = ProcessInfo
|
package/lib/child_process.cjs
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
14
|
+
).then(o => others = o)
|
|
15
|
+
|
|
16
|
+
let hasLoad = (async () =>
|
|
16
17
|
(await others).filter(loader => typeof loader.load === 'function'))()
|
|
17
|
-
|
|
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
|
+
"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
|
}
|