@zwa73/utils 1.0.100 → 1.0.101
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/dist/UtilCom.js +1 -1
- package/dist/UtilFunctions.d.ts +4 -2
- package/dist/UtilFunctions.js +11 -4
- package/package.json +3 -3
- package/scripts/compile.ps1 +5 -0
- package/scripts/watch.ps1 +10 -0
- package/src/UtilCom.ts +1 -1
- package/src/UtilFunctions.ts +9 -4
package/dist/UtilCom.js
CHANGED
package/dist/UtilFunctions.d.ts
CHANGED
|
@@ -48,9 +48,11 @@ export declare class UtilFunc {
|
|
|
48
48
|
*/
|
|
49
49
|
static sleep<T>(timeMs: number, result: T): Promise<T>;
|
|
50
50
|
/**封装的 cp.exec 执行一段指令 指令完成后返回 Promise
|
|
51
|
-
* @param command 指令文本
|
|
51
|
+
* @param command - 指令文本
|
|
52
|
+
* @param outlvl - 普通输出的日志等级
|
|
53
|
+
* @param errlvl - 错误的日志等级
|
|
52
54
|
*/
|
|
53
|
-
static exec(command: string): Promise<{
|
|
55
|
+
static exec(command: string, outlvl?: LogLevel, errlvl?: LogLevel): Promise<{
|
|
54
56
|
stdout: string;
|
|
55
57
|
stderr: string;
|
|
56
58
|
}>;
|
package/dist/UtilFunctions.js
CHANGED
|
@@ -102,15 +102,22 @@ class UtilFunc {
|
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
/**封装的 cp.exec 执行一段指令 指令完成后返回 Promise
|
|
105
|
-
* @param command 指令文本
|
|
105
|
+
* @param command - 指令文本
|
|
106
|
+
* @param outlvl - 普通输出的日志等级
|
|
107
|
+
* @param errlvl - 错误的日志等级
|
|
106
108
|
*/
|
|
107
|
-
static exec(command) {
|
|
109
|
+
static exec(command, outlvl, errlvl) {
|
|
108
110
|
return new Promise((resolve, reject) => {
|
|
109
111
|
cp.exec(command, (error, stdout, stderr) => {
|
|
110
112
|
if (error)
|
|
111
113
|
reject(error);
|
|
112
|
-
else
|
|
114
|
+
else {
|
|
115
|
+
if (stdout && outlvl)
|
|
116
|
+
UtilLogger_1.SLogger.log(outlvl, stdout);
|
|
117
|
+
if (stderr && errlvl)
|
|
118
|
+
UtilLogger_1.SLogger.log(errlvl, stderr);
|
|
113
119
|
resolve({ stdout, stderr });
|
|
120
|
+
}
|
|
114
121
|
});
|
|
115
122
|
});
|
|
116
123
|
}
|
|
@@ -526,7 +533,7 @@ class UtilFunc {
|
|
|
526
533
|
e.stack = [stackLines[0]].concat(stackLines.slice(2)).join('\n'); // 移除第一行的堆栈信息
|
|
527
534
|
Object.assign(e, opt);
|
|
528
535
|
if (lvl) {
|
|
529
|
-
|
|
536
|
+
//SLogger.log(lvl,message);
|
|
530
537
|
UtilLogger_1.SLogger.log(lvl, e.stack);
|
|
531
538
|
}
|
|
532
539
|
throw e;
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zwa73/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.101",
|
|
4
4
|
"description": "my utils",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "call npm run compile && jest",
|
|
8
8
|
"postinstall": "start node ./scripts/postinstall.js",
|
|
9
9
|
"release": "call npm run compile && call node release.js && call npm publish --access public",
|
|
10
|
-
"compile": "
|
|
11
|
-
"watch": "
|
|
10
|
+
"compile": "powershell scripts/compile",
|
|
11
|
+
"watch": "powershell scripts/watch"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"zwa73"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# 定义一个函数来运行脚本
|
|
2
|
+
function New-Script {
|
|
3
|
+
param($command)
|
|
4
|
+
# 在后台运行命令
|
|
5
|
+
Start-Process -NoNewWindow -FilePath "powershell" -ArgumentList "-Command", $command
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
# 开始运行脚本
|
|
9
|
+
New-Script "tsc -w -p tsconfig.compile.json"
|
|
10
|
+
New-Script "tsc-alias -w -p tsconfig.compile.json"
|
package/src/UtilCom.ts
CHANGED
package/src/UtilFunctions.ts
CHANGED
|
@@ -102,16 +102,21 @@ static async sleep<T>(timeMs: number, result?:T): Promise<T|undefined> {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/**封装的 cp.exec 执行一段指令 指令完成后返回 Promise
|
|
105
|
-
* @param command 指令文本
|
|
105
|
+
* @param command - 指令文本
|
|
106
|
+
* @param outlvl - 普通输出的日志等级
|
|
107
|
+
* @param errlvl - 错误的日志等级
|
|
106
108
|
*/
|
|
107
|
-
static exec(command: string) {
|
|
109
|
+
static exec(command: string,outlvl?:LogLevel,errlvl?:LogLevel) {
|
|
108
110
|
return new Promise<{ stdout:string, stderr:string }>
|
|
109
111
|
((resolve, reject) => {
|
|
110
112
|
cp.exec(command, (error, stdout, stderr) => {
|
|
111
113
|
if (error)
|
|
112
114
|
reject(error);
|
|
113
|
-
else
|
|
115
|
+
else{
|
|
116
|
+
if(stdout && outlvl) SLogger.log(outlvl,stdout);
|
|
117
|
+
if(stderr && errlvl) SLogger.log(errlvl,stderr);
|
|
114
118
|
resolve({ stdout, stderr });
|
|
119
|
+
}
|
|
115
120
|
});
|
|
116
121
|
});
|
|
117
122
|
}
|
|
@@ -592,7 +597,7 @@ static throwError(message:string,lvl?:LogLevel,opt?:{}):never{
|
|
|
592
597
|
e.stack = [stackLines[0]].concat(stackLines.slice(2)).join('\n'); // 移除第一行的堆栈信息
|
|
593
598
|
Object.assign(e, opt);
|
|
594
599
|
if(lvl){
|
|
595
|
-
SLogger.log(lvl,message);
|
|
600
|
+
//SLogger.log(lvl,message);
|
|
596
601
|
SLogger.log(lvl,e.stack);
|
|
597
602
|
}
|
|
598
603
|
throw e;
|