xshell 1.2.15 → 1.2.17
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/package.json +5 -5
- package/process.d.ts +3 -2
- package/process.js +19 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xshell",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@babel/parser": "^7.26.9",
|
|
54
54
|
"@babel/traverse": "^7.26.9",
|
|
55
55
|
"@koa/cors": "^5.0.0",
|
|
56
|
-
"@stylistic/eslint-plugin": "^4.0.
|
|
56
|
+
"@stylistic/eslint-plugin": "^4.0.1",
|
|
57
57
|
"@svgr/webpack": "^8.1.0",
|
|
58
58
|
"@types/sass-loader": "^8.0.9",
|
|
59
59
|
"@types/ws": "^8.5.14",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"commander": "^13.1.0",
|
|
68
68
|
"css-loader": "^7.1.2",
|
|
69
69
|
"emoji-regex": "^10.4.0",
|
|
70
|
-
"eslint": "^9.
|
|
70
|
+
"eslint": "^9.21.0",
|
|
71
71
|
"eslint-plugin-import": "^2.31.0",
|
|
72
72
|
"eslint-plugin-react": "^7.37.4",
|
|
73
73
|
"gulp-sort": "^2.0.0",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"vinyl-fs": "^4.0.0",
|
|
101
101
|
"webpack": "^5.98.0",
|
|
102
102
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
103
|
-
"ws": "^8.18.
|
|
103
|
+
"ws": "^8.18.1"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
106
|
"@babel/types": "^7.26.9",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"@types/koa": "^2.15.0",
|
|
113
113
|
"@types/koa-compress": "^4.0.6",
|
|
114
114
|
"@types/mime-types": "^2.1.4",
|
|
115
|
-
"@types/node": "^22.13.
|
|
115
|
+
"@types/node": "^22.13.5",
|
|
116
116
|
"@types/react": "^19.0.10",
|
|
117
117
|
"@types/through2": "^2.0.41",
|
|
118
118
|
"@types/tough-cookie": "^4.0.5",
|
package/process.d.ts
CHANGED
|
@@ -68,6 +68,8 @@ export interface StartOptions extends BaseOptions {
|
|
|
68
68
|
print?: boolean;
|
|
69
69
|
}
|
|
70
70
|
export declare function get_command(exe: string, args?: string[]): string;
|
|
71
|
+
/** 处理 print 选项 */
|
|
72
|
+
export declare function get_print_options(print?: boolean | Partial<FullPrintOptions>, stdout?: string | boolean, stderr?: string | boolean): FullPrintOptions;
|
|
71
73
|
export interface SubProcess<TOutput extends string | Buffer = string> extends ChildProcess {
|
|
72
74
|
/** 由创建进程的调用者设置的,用于区分、识别、记忆的可选名称 */
|
|
73
75
|
title?: string;
|
|
@@ -134,12 +136,11 @@ export interface CallError<TOutput extends string | Buffer = string> extends Err
|
|
|
134
136
|
code: number;
|
|
135
137
|
signal: NodeJS.Signals;
|
|
136
138
|
command: string;
|
|
137
|
-
child: SubProcess<TOutput>;
|
|
138
139
|
print: FullPrintOptions;
|
|
139
140
|
}
|
|
140
141
|
export declare class CallError<TOutput extends string | Buffer = string> extends Error {
|
|
141
142
|
name: "CallError";
|
|
142
|
-
constructor({ message, pid, stdout, stderr, code, signal, command,
|
|
143
|
+
constructor({ message, pid, stdout, stderr, code, signal, command, print }: CallResult<TOutput>);
|
|
143
144
|
[inspect.custom](depth: number, options: InspectOptions, inspect: Function): string;
|
|
144
145
|
}
|
|
145
146
|
/** 调用 exe 启动子进程,等待并获取返回结果,错误时抛出 CallError
|
package/process.js
CHANGED
|
@@ -16,6 +16,22 @@ export function get_command(exe, args) {
|
|
|
16
16
|
? ` ${args.map(arg => arg.quote_if_space()).join(' ')}`
|
|
17
17
|
: '');
|
|
18
18
|
}
|
|
19
|
+
/** 处理 print 选项 */
|
|
20
|
+
export function get_print_options(print = true, stdout = true, stderr = true) {
|
|
21
|
+
if (typeof print === 'boolean')
|
|
22
|
+
print = {
|
|
23
|
+
command: print,
|
|
24
|
+
code: print,
|
|
25
|
+
stdout: print,
|
|
26
|
+
stderr: print
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
command: print.command ?? true,
|
|
30
|
+
code: print.code ?? true,
|
|
31
|
+
stdout: stdout === true && (print.stdout ?? true),
|
|
32
|
+
stderr: stderr === true && (print.stderr ?? true)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
19
35
|
async function prepare_spawn(detached, exe, args, { cwd, window: _window = false, envs,
|
|
20
36
|
// @ts-ignore
|
|
21
37
|
input, stdin = Boolean(input), stdout = !detached, stderr = stdout, print = true, proxy, }) {
|
|
@@ -70,20 +86,8 @@ input, stdin = Boolean(input), stdout = !detached, stderr = stdout, print = true
|
|
|
70
86
|
await close_all_handles();
|
|
71
87
|
throw error;
|
|
72
88
|
}
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
print = {
|
|
76
|
-
command: print,
|
|
77
|
-
code: print,
|
|
78
|
-
stdout: print,
|
|
79
|
-
stderr: print
|
|
80
|
-
};
|
|
81
|
-
print = {
|
|
82
|
-
command: print.command ?? true,
|
|
83
|
-
code: print.code ?? true,
|
|
84
|
-
stdout: stdout && (print.stdout ?? true),
|
|
85
|
-
stderr: stderr && (print.stderr ?? true)
|
|
86
|
-
};
|
|
89
|
+
// 处理 print
|
|
90
|
+
print = get_print_options(print, stdout, stderr);
|
|
87
91
|
const command = get_command(exe, args);
|
|
88
92
|
if (print.command)
|
|
89
93
|
console.log(command.blue);
|
|
@@ -163,7 +167,7 @@ export async function start(exe, args = [], options = {}) {
|
|
|
163
167
|
}
|
|
164
168
|
export class CallError extends Error {
|
|
165
169
|
name = 'CallError';
|
|
166
|
-
constructor({ message, pid, stdout, stderr, code, signal, command,
|
|
170
|
+
constructor({ message, pid, stdout, stderr, code, signal, command, print }) {
|
|
167
171
|
super(message);
|
|
168
172
|
// defineProperty 默认 enumerable: false,不会在 inspect 中显示
|
|
169
173
|
Object.defineProperties(this, {
|
|
@@ -173,7 +177,6 @@ export class CallError extends Error {
|
|
|
173
177
|
code: { value: code },
|
|
174
178
|
signal: { value: signal },
|
|
175
179
|
command: { value: command },
|
|
176
|
-
child: { value: child },
|
|
177
180
|
print: { value: print }
|
|
178
181
|
});
|
|
179
182
|
}
|