@zwa73/utils 1.0.123 → 1.0.124

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.
@@ -56,7 +56,9 @@ export declare class UtilFunc {
56
56
  */
57
57
  static sleep<T>(timeMs: number, result: T): Promise<T>;
58
58
  /**是否需要检查环境 */
59
- static checkEnv: boolean;
59
+ private static checkEnv;
60
+ /**是否有正在运行的exec */
61
+ private static originalExecTitle;
60
62
  /**封装的 cp.spawn 执行一段指令,指令运行时实时返回输出
61
63
  * @param command - 指令文本
62
64
  * @param opt - 可选参数
@@ -110,6 +110,8 @@ class UtilFunc {
110
110
  }
111
111
  /**是否需要检查环境 */
112
112
  static checkEnv = true;
113
+ /**是否有正在运行的exec */
114
+ static originalExecTitle = UtilSymbol_1.None;
113
115
  /**封装的 cp.spawn 执行一段指令,指令运行时实时返回输出
114
116
  * @param command - 指令文本
115
117
  * @param opt - 可选参数
@@ -126,6 +128,10 @@ class UtilFunc {
126
128
  UtilFunc.checkEnv = false;
127
129
  }
128
130
  env.PATH = penv + path_1.default.delimiter + env.PATH;
131
+ // 保存原来的标题
132
+ UtilFunc.originalExecTitle = UtilFunc.originalExecTitle == UtilSymbol_1.None
133
+ ? process.title
134
+ : UtilFunc.originalExecTitle;
129
135
  const child = cp.spawn(command, { shell: true, env });
130
136
  let stdout = '';
131
137
  let stderr = '';
@@ -141,6 +147,10 @@ class UtilFunc {
141
147
  });
142
148
  child.on('error', reject);
143
149
  child.on('close', (code) => {
150
+ if (UtilFunc.originalExecTitle != UtilSymbol_1.None) {
151
+ process.title = UtilFunc.originalExecTitle;
152
+ UtilFunc.originalExecTitle = UtilSymbol_1.None;
153
+ }
144
154
  if (code !== 0)
145
155
  UtilLogger_1.SLogger.warn(`UtilFunc.exec 命令:"${command}" 结束 代码为:${code}`);
146
156
  resolve({ stdout, stderr });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zwa73/utils",
3
- "version": "1.0.123",
3
+ "version": "1.0.124",
4
4
  "description": "my utils",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -114,7 +114,9 @@ static async sleep<T>(timeMs: number, result?:T): Promise<T|undefined> {
114
114
  }
115
115
 
116
116
  /**是否需要检查环境 */
117
- static checkEnv = true;
117
+ private static checkEnv = true;
118
+ /**是否有正在运行的exec */
119
+ private static originalExecTitle:None|string = None;
118
120
  /**封装的 cp.spawn 执行一段指令,指令运行时实时返回输出
119
121
  * @param command - 指令文本
120
122
  * @param opt - 可选参数
@@ -134,6 +136,11 @@ static exec(command: string, opt?:ExecOpt) {
134
136
 
135
137
  env.PATH = penv + opath.delimiter + env.PATH;
136
138
 
139
+ // 保存原来的标题
140
+ UtilFunc.originalExecTitle = UtilFunc.originalExecTitle==None
141
+ ? process.title
142
+ : UtilFunc.originalExecTitle;
143
+
137
144
  const child = cp.spawn(command, { shell: true, env });
138
145
 
139
146
  let stdout = '';
@@ -150,6 +157,10 @@ static exec(command: string, opt?:ExecOpt) {
150
157
  });
151
158
  child.on('error', reject);
152
159
  child.on('close', (code) => {
160
+ if(UtilFunc.originalExecTitle!=None){
161
+ process.title = UtilFunc.originalExecTitle;
162
+ UtilFunc.originalExecTitle = None;
163
+ }
153
164
  if (code!==0) SLogger.warn(`UtilFunc.exec 命令:"${command}" 结束 代码为:${code}`);
154
165
  resolve({ stdout, stderr });
155
166
  });