xshell 1.2.28 → 1.2.29

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/apps.d.ts CHANGED
@@ -5,13 +5,11 @@ export declare let npm: {
5
5
  /** node.exe E:/sdk/nodejs/node_modules/corepack/dist/pnpm.js install
6
6
  - cwd
7
7
  - pkgs?: `[ ]` */
8
- install(cwd: string, pkgs?: string[], { save_dev, save_peer, legacy, force, term, inspect, break: _break, }?: {
8
+ install(cwd: string, pkgs?: string[], { save_dev, save_peer, legacy, force, break: _break, }?: {
9
9
  save_dev?: boolean;
10
10
  save_peer?: boolean;
11
11
  legacy?: boolean;
12
12
  force?: boolean;
13
- term?: boolean;
14
- inspect?: boolean;
15
13
  break?: boolean;
16
14
  }): Promise<void>;
17
15
  };
package/apps.js CHANGED
@@ -8,7 +8,7 @@ export let npm = {
8
8
  /** node.exe E:/sdk/nodejs/node_modules/corepack/dist/pnpm.js install
9
9
  - cwd
10
10
  - pkgs?: `[ ]` */
11
- async install(cwd, pkgs = [], { save_dev = false, save_peer = false, legacy = false, force = false, term = false, inspect = false, break: _break = false, } = {}) {
11
+ async install(cwd, pkgs = [], { save_dev = false, save_peer = false, legacy = false, force = false, break: _break = false, } = {}) {
12
12
  const args = [
13
13
  'install',
14
14
  ...util.inspect.defaultOptions.colors ? ['--color'] : [],
@@ -19,6 +19,6 @@ export let npm = {
19
19
  ...pkgs || []
20
20
  ];
21
21
  await this.call(cwd, this.bin, args);
22
- },
22
+ }
23
23
  };
24
24
  //# sourceMappingURL=apps.js.map
package/file.d.ts CHANGED
@@ -27,14 +27,16 @@ export declare function fopen(fp: string, flags?: string | number, { mode, print
27
27
  flags: string | number;
28
28
  mode: fs.Mode;
29
29
  }>;
30
- export declare function fread(fp: string): Promise<string>;
31
- export declare function fread(fp: string, options?: {
32
- encoding: 'binary';
30
+ export interface FReadOptions {
31
+ encoding?: Encoding | 'binary';
33
32
  print?: boolean;
33
+ }
34
+ export declare function fread(fp: string | FileHandle): Promise<string>;
35
+ export declare function fread(fp: string | FileHandle, options?: FReadOptions & {
36
+ encoding: 'binary';
34
37
  }): Promise<Buffer>;
35
- export declare function fread(fp: string, options?: {
38
+ export declare function fread(fp: string | FileHandle, options?: FReadOptions & {
36
39
  encoding?: Encoding;
37
- print?: boolean;
38
40
  }): Promise<string>;
39
41
  /** 读取文件,划分为行,并去掉最后一个 \n 之后的 '' */
40
42
  export declare function fread_lines(fp: string, options?: {
@@ -56,6 +58,7 @@ export declare function fequals(fp_left: string, fp_right: string, { print }?: {
56
58
  }): Promise<boolean>;
57
59
  export interface FWriteOptions {
58
60
  print?: boolean;
61
+ mtime?: number;
59
62
  }
60
63
  /** 写入 data 到 fp 路径所指的文件
61
64
  会在因不存在父文件夹导致写入失败时,自动创建父文件夹,并再次尝试写入
@@ -67,8 +70,8 @@ export interface FWriteOptions {
67
70
  - Uint8Array, Buffer: 写入二进制 buffer
68
71
  - any: 通过 JSON.stringify 转为文本后写入文件
69
72
  - options?:
70
- - dir?: 文件夹
71
- - print?: `true` */
73
+ - print?: `true`
74
+ - mtime?: 在写入后设置修改时间 */
72
75
  export declare function fwrite(fp: string, data: string | Uint8Array | any, options?: FWriteOptions): Promise<string>;
73
76
  export declare function fwrite(fp: FileHandle, data: string | Uint8Array | any, options?: FWriteOptions): Promise<FileHandle>;
74
77
  export declare function fwrite(fp: string | FileHandle, data: string | Uint8Array | any, options?: FWriteOptions): Promise<string | FileHandle>;
@@ -104,7 +107,7 @@ export declare function flist(fpd: string, options?: FListOptions & {
104
107
  stats: true;
105
108
  }): Promise<FStats[]>;
106
109
  export declare function flist(fpd: string, options?: FListOptions): Promise<string[]>;
107
- export declare function fstat(fp: string): Promise<FStats>;
110
+ export declare function fstat(fp: string | FileHandle): Promise<FStats>;
108
111
  export declare function flstat(fp: string): Promise<FStats>;
109
112
  export declare function ffstat(handle: fsp.FileHandle): Promise<fs.BigIntStats>;
110
113
  /** 删除文件或文件夹,返回是否实际进行了删除操作
@@ -140,7 +143,7 @@ export interface FCopyOptions {
140
143
 
141
144
  @example
142
145
  fcopy('D:/temp/camera/', 'D:/camera/') */
143
- export declare function fcopy(fp_src: string, fp_dst: string, { print, overwrite, filter, }?: FCopyOptions): Promise<void>;
146
+ export declare function fcopy(fp_src: string, fp_dst: string, { print, overwrite, filter, }?: FCopyOptions): Promise<string>;
144
147
  export interface FMoveOptions {
145
148
  overwrite?: boolean;
146
149
  print?: boolean;
@@ -155,7 +158,7 @@ export interface FMoveOptions {
155
158
 
156
159
  @example
157
160
  fmove('D:/temp/camera/', 'D:/camera/') */
158
- export declare function fmove(fp_src: string, fp_dst: string, { overwrite, print }?: FMoveOptions): Promise<void>;
161
+ export declare function fmove(fp_src: string, fp_dst: string, { overwrite, print }?: FMoveOptions): Promise<string>;
159
162
  /** 重命名文件 rename file
160
163
  - fp: 当前文件名/路径 current filename/path
161
164
  - fp_: 新的文件名/路径 new filename/path
@@ -168,6 +171,11 @@ export declare function frename(fp: string, fp_: string, { fpd, print, overwrite
168
171
  print?: boolean;
169
172
  overwrite?: boolean;
170
173
  }): Promise<void>;
174
+ export interface FMkdirOptions {
175
+ print?: boolean;
176
+ /** `0o777` A file mode. If a string is passed, it is parsed as an octal integer. */
177
+ mode?: string | number;
178
+ }
171
179
  /**
172
180
  递归创建文件夹,确保 fpd 指向的文件夹存在 Create folders recursively, make sure the folder pointed to by fpd exists
173
181
  返回首个创建的文件夹或 undefined Returns the first created folder or undefined
@@ -176,11 +184,7 @@ export declare function frename(fp: string, fp_: string, { fpd, print, overwrite
176
184
  - options?:
177
185
  - print?: `true`
178
186
  - mode?: `'0o777'` */
179
- export declare function fmkdir(fpd: string, { print, mode, }?: {
180
- print?: boolean;
181
- /** `0o777` A file mode. If a string is passed, it is parsed as an octal integer. */
182
- mode?: string | number;
183
- }): Promise<string>;
187
+ export declare function fmkdir(fpd: string, { print, mode }?: FMkdirOptions): Promise<string>;
184
188
  /** 创建软链接
185
189
  - fp_real: 现在真实文件/文件夹的路径
186
190
  - fp_link: 目标链接文件/文件夹的路径 */
@@ -225,3 +229,4 @@ export declare function ftail(fp: string, handler: (lines: string[]) => void | P
225
229
  export declare function freplace(fp: string, pattern: string | RegExp, replacement: string, { print }?: {
226
230
  print?: boolean;
227
231
  }): Promise<void>;
232
+ export declare function log_action(action: string, fp_src: string, fp_dst: string, sep?: string): void;
package/file.js CHANGED
@@ -5,9 +5,10 @@ import { to_json } from "./prototype.js";
5
5
  import { pack, parse } from "./io.js";
6
6
  import { path } from "./path.js";
7
7
  import { check, Lock, WritableMemoryStream, url_width, throttle } from "./utils.js";
8
+ import { noprint } from "./process.js";
8
9
  export { fsp };
9
10
  export const encodings = ['utf-8', 'gb18030', 'shift-jis', 'utf-16le'];
10
- export const ramdisk = fexists('T:/TEMP/', { print: false });
11
+ export const ramdisk = fexists('T:/TEMP/', noprint);
11
12
  /** fp 所指向的 文件/ 文件夹 是否存在
12
13
  Does the file/folder pointed to by fp exist? */
13
14
  export function fexists(fp, { print = true } = {}) {
@@ -27,15 +28,21 @@ export function fexists(fp, { print = true } = {}) {
27
28
  export async function fopen(fp, flags = 'r', { mode, print } = {}) {
28
29
  if (print)
29
30
  console.log(t('打开文件'), fp);
30
- await fmkdir(fp.fdir, { print: false });
31
+ await fmkdir(fp.fdir, noprint);
31
32
  return Object.assign(await fsp.open(fp, flags, mode), { fp, flags, mode });
32
33
  }
33
34
  export async function fread(fp, { encoding = 'utf-8', print = true } = {}) {
34
- check(!fp.isdir, t('fp 必须是文件,不能以 / 结尾'));
35
- check(path.isAbsolute(fp), `${t('fp 必须是绝对路径:')} ${fp}`);
36
- check(encoding !== 'auto');
37
- if (print)
38
- console.log(t('读取'), fp);
35
+ const is_handle = typeof fp === 'object' && fp && 'fd' in fp;
36
+ if (is_handle) {
37
+ if (print && fp.fp)
38
+ console.log('读取', fp);
39
+ }
40
+ else {
41
+ check(!fp.isdir, 'fp 必须是文件,不能以 / 结尾');
42
+ check(path.isAbsolute(fp), `fp 必须是绝对路径: ${fp}`);
43
+ if (print)
44
+ console.log('读取', fp);
45
+ }
39
46
  switch (encoding) {
40
47
  case 'utf-8':
41
48
  return fsp.readFile(fp, { encoding: 'utf-8' });
@@ -75,30 +82,44 @@ export async function fequals(fp_left, fp_right, { print = true } = {}) {
75
82
  return false;
76
83
  }
77
84
  }
78
- export async function fwrite(fp, data, { print = true } = {}) {
85
+ export async function fwrite(fp, data, { print = true, mtime } = {}) {
79
86
  const is_handle = typeof fp === 'object' && fp && 'fd' in fp;
80
87
  if (is_handle) {
81
88
  if (print)
82
- console.log(t('写入'), fp.fp);
89
+ console.log('写入', fp.fp);
83
90
  }
84
91
  else {
85
- check(path.isAbsolute(fp), `${t('fp 必须是绝对路径,当前为:')} ${fp}`);
92
+ check(path.isAbsolute(fp), `fp 必须是绝对路径,当前为: ${fp}`);
86
93
  if (print)
87
- console.log(t('写入'), fp);
94
+ console.log('写入', fp);
88
95
  }
89
96
  if (!isUint8Array(data) && typeof data !== 'string')
90
97
  data = to_json(data);
98
+ // 需要设置修改时间,先打开文件再写入
99
+ if (mtime !== undefined && !is_handle) {
100
+ let handle = await fopen(fp, 'w', noprint);
101
+ try {
102
+ await handle.write(data, 0);
103
+ await handle.utimes(mtime, mtime);
104
+ }
105
+ finally {
106
+ await handle.close();
107
+ }
108
+ return fp;
109
+ }
91
110
  try {
92
111
  await fsp.writeFile(fp, data);
93
112
  }
94
113
  catch (error) {
95
114
  if (error.code === 'ENOENT' && !is_handle) {
96
- await fmkdir(fp.fdir, { print: false });
115
+ await fmkdir(fp.fdir, noprint);
97
116
  await fsp.writeFile(fp, data);
98
117
  }
99
118
  else
100
119
  throw error;
101
120
  }
121
+ if (mtime !== undefined)
122
+ await fp.utimes(mtime, mtime);
102
123
  return fp;
103
124
  }
104
125
  export async function fpack(fp, data, options) {
@@ -115,7 +136,7 @@ export async function fappend(fp, data, { print = true } = {}) {
115
136
  }
116
137
  catch (error) {
117
138
  if (error.code === 'ENOENT') {
118
- await fmkdir(fp.fdir, { print: false });
139
+ await fmkdir(fp.fdir, noprint);
119
140
  await fsp.appendFile(fp, data);
120
141
  }
121
142
  else
@@ -213,9 +234,17 @@ export async function flist(fpd, options = {}) {
213
234
  return fps;
214
235
  }
215
236
  export async function fstat(fp) {
216
- check(path.isAbsolute(fp), t("fstat: 参数 fp: '{{fp}}' 必须是绝对路径", { fp }));
217
- let stat = await fsp.stat(fp, { bigint: true });
218
- stat.fp = fp;
237
+ let stat;
238
+ if (typeof fp === 'object' && fp && 'fd' in fp) {
239
+ stat = await fp.stat({ bigint: true });
240
+ if (fp.fp)
241
+ stat.fp = fp.fp;
242
+ }
243
+ else {
244
+ check(path.isAbsolute(fp), `fstat: 参数 fp: '${fp}' 必须是绝对路径`);
245
+ stat = await fsp.stat(fp, { bigint: true });
246
+ stat.fp = fp;
247
+ }
219
248
  return stat;
220
249
  }
221
250
  export async function flstat(fp) {
@@ -259,8 +288,8 @@ export async function fdelete(fp, { print = true } = {}) {
259
288
  }
260
289
  /** 清空文件夹中的内容,实际为删除该文件夹后新建 */
261
290
  export async function fdclear(fpd, { print = true } = {}) {
262
- await fdelete(fpd, { print: false });
263
- await fmkdir(fpd, { print: false });
291
+ await fdelete(fpd, noprint);
292
+ await fmkdir(fpd, noprint);
264
293
  if (print)
265
294
  console.log(`清空了文件夹 ${fpd}`);
266
295
  }
@@ -319,6 +348,7 @@ export async function fcopy(fp_src, fp_dst, { print = true, overwrite = true, fi
319
348
  else
320
349
  throw error;
321
350
  }
351
+ return fp_dst;
322
352
  }
323
353
  /** 移动文件或文件夹
324
354
  相同分区 / 文件系统下使用 rename, 否则 fallback 到复制后删除源文件
@@ -335,12 +365,12 @@ export async function fmove(fp_src, fp_dst, { overwrite = false, print = true }
335
365
  check(path.isAbsolute(fp_src) && path.isAbsolute(fp_dst), t('fp_src 和 fp_dst 必须为完整路径'));
336
366
  if (print)
337
367
  log_action('移动', fp_src, fp_dst);
338
- if (!overwrite && fexists(fp_dst, { print: false }))
368
+ if (!overwrite && fexists(fp_dst, noprint))
339
369
  throw new Error(`${t('已存在')} ${fp_dst}`);
340
- await fmkdir(fp_dst.fdir, { print: false });
370
+ await fmkdir(fp_dst.fdir, noprint);
341
371
  async function copy_and_delete() {
342
372
  await fcopy(fp_src, fp_dst, { overwrite, print: false });
343
- await fdelete(fp_src, { print: false });
373
+ await fdelete(fp_src, noprint);
344
374
  }
345
375
  if (fp_src[0] !== fp_dst[0] || overwrite)
346
376
  await copy_and_delete();
@@ -354,6 +384,7 @@ export async function fmove(fp_src, fp_dst, { overwrite = false, print = true }
354
384
  else
355
385
  throw error;
356
386
  }
387
+ return fp_dst;
357
388
  }
358
389
  /** 重命名文件 rename file
359
390
  - fp: 当前文件名/路径 current filename/path
@@ -371,7 +402,7 @@ export async function frename(fp, fp_, { fpd, print = true, overwrite = true } =
371
402
  check(path.isAbsolute(fp) && path.isAbsolute(fp_), t('fp 和 fp_ 必须是绝对路径'));
372
403
  if (print)
373
404
  log_action('重命名', fp, fp_);
374
- if (!overwrite && fexists(fp_, { print: false }))
405
+ if (!overwrite && fexists(fp_, noprint))
375
406
  throw new Error(`${t('已存在')} ${fp}`);
376
407
  await fsp.rename(fp, fp_);
377
408
  }
@@ -383,13 +414,13 @@ export async function frename(fp, fp_, { fpd, print = true, overwrite = true } =
383
414
  - options?:
384
415
  - print?: `true`
385
416
  - mode?: `'0o777'` */
386
- export async function fmkdir(fpd, { print = true, mode, } = {}) {
387
- check(path.isAbsolute(fpd), t('fpd 必须是绝对路径: ') + fpd);
388
- check(fpd.isdir, t('fpd 必须以 / 结尾: ') + fpd);
417
+ export async function fmkdir(fpd, { print = true, mode } = {}) {
418
+ check(path.isAbsolute(fpd), `fpd 必须是绝对路径: ${fpd}`);
419
+ check(fpd.isdir, `fpd 必须以 / 结尾: ${fpd}`);
389
420
  // 类似 D:/ 这样的根路径,调用 fsp.mkdir 会报错无权限
390
421
  if (fpd.length === 3 &&
391
422
  'A' <= fpd[0] && fpd[0] <= 'Z' && fpd[1] === ':' && fpd[2] === '/')
392
- if (fexists(fpd)) {
423
+ if (fexists(fpd, noprint)) {
393
424
  if (print)
394
425
  console.log(t('已存在文件夹'), fpd);
395
426
  return fpd;
@@ -414,7 +445,7 @@ export async function flink(fp_real, fp_link, { junction = false, print = true,
414
445
  const is_fpd_real = fp_real.isdir;
415
446
  const is_fpd_link = fp_link.isdir;
416
447
  check(is_fpd_real === is_fpd_link, 'fp_real 和 fp_link 必须同为文件路径或文件夹路径');
417
- if (fexists(fp_link, { print: false }))
448
+ if (fexists(fp_link, noprint))
418
449
  if (!skip_existing)
419
450
  throw new Error(`存在同名${is_fpd_link ? '文件夹' : '文件'}: ${fp_link},无法创建链接`);
420
451
  else {
@@ -464,7 +495,7 @@ async function _zip(data, fp_zip, { dirname, print = { files: true, info: true }
464
495
  dirname = fpd_src.fname;
465
496
  if (!dirname.isdir)
466
497
  throw new Error('dirname 需要以 / 结尾');
467
- entries = Object.fromEntries((await flist(fpd_src, { print: false }))
498
+ entries = Object.fromEntries((await flist(fpd_src, noprint))
468
499
  .map(fp => ([dirname + fp, fpd_src + fp])));
469
500
  }
470
501
  else {
@@ -565,7 +596,7 @@ export async function freplace(fp, pattern, replacement, { print = true } = {})
565
596
  await fwrite(fp, (await fread(fp, { print }))
566
597
  .replaceAll(pattern, replacement), { print });
567
598
  }
568
- function log_action(action, fp_src, fp_dst, sep = '->') {
599
+ export function log_action(action, fp_src, fp_dst, sep = '->') {
569
600
  console.log(`${`${action} ${fp_src}`.pad(url_width)} ${sep} ${fp_dst}`);
570
601
  }
571
602
  //# sourceMappingURL=file.js.map
package/git.d.ts CHANGED
@@ -27,6 +27,7 @@ export declare class Git {
27
27
  hash: string;
28
28
  message: string;
29
29
  }[]>;
30
+ get_last_commit_hash(short?: boolean): Promise<string>;
30
31
  fetch({ print, remote }?: {
31
32
  print?: boolean;
32
33
  remote?: string;
package/git.js CHANGED
@@ -1,4 +1,4 @@
1
- import { call, print_no_command } from "./process.js";
1
+ import { call, noprint, print_no_command } from "./process.js";
2
2
  import { fread, fmkdir } from "./file.js";
3
3
  export class Git {
4
4
  static exe = 'git';
@@ -86,6 +86,11 @@ export class Git {
86
86
  };
87
87
  });
88
88
  }
89
+ async get_last_commit_hash(short = true) {
90
+ const hash = (await fread(`${this.cwd}.git/refs/heads/${await this.get_branch()}`, noprint))
91
+ .trim();
92
+ return short ? hash.slice(0, 6) : hash;
93
+ }
89
94
  async fetch({ print = true, remote } = {}) {
90
95
  await this.call([
91
96
  'fetch',
package/net.d.ts CHANGED
@@ -285,5 +285,5 @@ export declare class RemoteClient {
285
285
  [inspect.custom](): {
286
286
  remote: string;
287
287
  websocket: string;
288
- } & Omit<this, "call" | "websocket" | typeof import("util").inspect.custom | "remote" | "send">;
288
+ } & Omit<this, "websocket" | typeof import("util").inspect.custom | "call" | "remote" | "send">;
289
289
  }
package/net.js CHANGED
@@ -108,7 +108,7 @@ export async function request(url, options = {}) {
108
108
  let headers = {
109
109
  'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5',
110
110
  'accept-encoding': 'gzip, deflate, br',
111
- 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36',
111
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
112
112
  'sec-ch-ua-platform': '"Windows"',
113
113
  'sec-ch-ua-platform-version': '"15.0.0"',
114
114
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.2.28",
3
+ "version": "1.2.29",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -56,10 +56,10 @@
56
56
  "@stylistic/eslint-plugin": "^4.2.0",
57
57
  "@svgr/webpack": "^8.1.0",
58
58
  "@types/sass-loader": "^8.0.9",
59
- "@types/ws": "^8.18.0",
60
- "@typescript-eslint/eslint-plugin": "^8.28.0",
61
- "@typescript-eslint/parser": "^8.28.0",
62
- "@typescript-eslint/utils": "^8.28.0",
59
+ "@types/ws": "^8.18.1",
60
+ "@typescript-eslint/eslint-plugin": "^8.29.0",
61
+ "@typescript-eslint/parser": "^8.29.0",
62
+ "@typescript-eslint/utils": "^8.29.0",
63
63
  "archiver": "^7.0.1",
64
64
  "chalk": "^5.4.1",
65
65
  "cli-table3": "^0.6.5",
@@ -80,11 +80,11 @@
80
80
  "map-stream": "^0.0.7",
81
81
  "mime-types": "^3.0.1",
82
82
  "ora": "^8.2.0",
83
- "react": "^19.0.0",
83
+ "react": "^19.1.0",
84
84
  "react-i18next": "^15.4.1",
85
85
  "react-object-model": "^1.2.23",
86
86
  "resolve-path": "^1.4.0",
87
- "sass": "^1.86.0",
87
+ "sass": "^1.86.2",
88
88
  "sass-loader": "^16.0.5",
89
89
  "source-map-loader": "^5.0.0",
90
90
  "strip-ansi": "^7.1.0",
@@ -95,7 +95,7 @@
95
95
  "tslib": "^2.8.1",
96
96
  "typescript": "^5.8.2",
97
97
  "ua-parser-js": "^2.0.3",
98
- "undici": "^7.5.0",
98
+ "undici": "^7.7.0",
99
99
  "vinyl": "^3.0.0",
100
100
  "vinyl-fs": "^4.0.0",
101
101
  "webpack": "^5.98.0",
@@ -112,8 +112,8 @@
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.14",
116
- "@types/react": "^19.0.12",
115
+ "@types/node": "^22.14.0",
116
+ "@types/react": "^19.1.0",
117
117
  "@types/through2": "^2.0.41",
118
118
  "@types/tough-cookie": "^4.0.5",
119
119
  "@types/ua-parser-js": "^0.7.39",
package/path.d.ts CHANGED
@@ -54,7 +54,7 @@ export declare function extname(path: string): string;
54
54
  /** `/` */
55
55
  export declare const sep = "/";
56
56
  /** The platform-specific file delimiter. ';' or ':'. */
57
- export declare const delimiter: ";" | ":";
57
+ export declare const delimiter: ":" | ";";
58
58
  /** Returns an object from a path string - the opposite of format().
59
59
  @param path path to evaluate.
60
60
  @throws {TypeError} if `path` is not a string. */
@@ -81,7 +81,7 @@ export declare let path: {
81
81
  basename: typeof basename;
82
82
  extname: typeof extname;
83
83
  sep: string;
84
- delimiter: ";" | ":";
84
+ delimiter: ":" | ";";
85
85
  parse: typeof parse;
86
86
  format: typeof format;
87
87
  toNamespacedPath: typeof toNamespacedPath;
package/process.d.ts CHANGED
@@ -189,6 +189,7 @@ export declare function launch(exe: string, args?: string[], options?: CallOptio
189
189
  export interface NodeJsOptions {
190
190
  inspect?: number | true;
191
191
  break?: boolean;
192
+ host?: string;
192
193
  }
193
194
  export interface CallNodeJsOptions extends CallOptions, NodeJsOptions {
194
195
  }
@@ -203,7 +204,8 @@ export interface CallNodeJsOptions extends CallOptions, NodeJsOptions {
203
204
  - stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理
204
205
  - throw_code?: `true` code 不为 0 时是否抛出异常
205
206
  - inspect?: nodejs debugger port, 填 9229 端口 (或者传 true) 可以用临时配置来调试
206
- - break?: break at first line */
207
+ - break?: break at first line
208
+ - host?: 指定 inspect 监听的 host (默认监听 localhost) */
207
209
  export declare function call_nodejs(js: string, args?: string[], options?: CallNodeJsOptions): Promise<CallResult<string>>;
208
210
  export interface StartNodeJsOptions extends StartOptions, NodeJsOptions {
209
211
  }
@@ -222,6 +224,7 @@ export declare function start_nodejs(js: string, args?: string[], options?: Star
222
224
  - inspect?: nodejs debugger port, 填 9229 端口 (或者传 true) 可以用临时配置来调试
223
225
  - break?: 在第一行停止 */
224
226
  export declare function launch_nodejs(js: string, args?: string[], options?: CallNodeJsOptions): Promise<SubProcess<string>>;
227
+ export declare function get_nodejs_args(js: string, args?: string[], { inspect, break: _break, host }?: NodeJsOptions): string[];
225
228
  /** 可选的向子进程输入内容,并等待子进程输出特定的内容,类似一次无返回值,仅有完成状态的 rpc 调用
226
229
  根据文本内容匹配其实不太好,实在是没有别的 rpc 方法再使用吧
227
230
  - ps: 子进程
package/process.js CHANGED
@@ -310,7 +310,8 @@ export async function launch(exe, args, options) {
310
310
  - stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理
311
311
  - throw_code?: `true` code 不为 0 时是否抛出异常
312
312
  - inspect?: nodejs debugger port, 填 9229 端口 (或者传 true) 可以用临时配置来调试
313
- - break?: break at first line */
313
+ - break?: break at first line
314
+ - host?: 指定 inspect 监听的 host (默认监听 localhost) */
314
315
  export async function call_nodejs(js, args, options) {
315
316
  return call(exe_nodejs, get_nodejs_args(js, args, options), options);
316
317
  }
@@ -333,10 +334,10 @@ export async function start_nodejs(js, args, options) {
333
334
  export async function launch_nodejs(js, args, options) {
334
335
  return launch(exe_nodejs, get_nodejs_args(js, args, options), options);
335
336
  }
336
- function get_nodejs_args(js, args = [], { inspect, break: _break } = {}) {
337
+ export function get_nodejs_args(js, args = [], { inspect, break: _break, host = 'localhost' } = {}) {
337
338
  return [
338
339
  '--enable-source-maps',
339
- ...inspect ? [`--inspect${_break ? '-brk' : ''}=localhost:${inspect === true ? 9229 : inspect}`] : [],
340
+ ...inspect ? [`--inspect${_break ? '-brk' : ''}=${host}:${inspect === true ? 9229 : inspect}`] : [],
340
341
  js,
341
342
  ...args
342
343
  ];