@@ -45,16 +45,22 @@ async function RunXmake(file: string, toolchain: string, sdk: string) {
45
45
}
46
46
47
47
async function RunXmakeConfig ( file : string , toolchain : string , sdk : string ) {
48
- const os = Deno . build . os ;
49
48
console . log ( { file } ) ;
50
- // console.log({ os });
51
- const cmd = os === "windows" ? "powershell.exe" : "bash" ;
49
+ const cwd = path . dirname ( file ) ;
52
50
const others = [
53
51
`xmake clean ` ,
54
52
` xmake f ${ toolchain ? "--toolchain=" + toolchain : "" } ${
55
53
sdk ? "--sdk=" + sdk : ""
56
54
} -y -v `,
57
55
] ;
56
+ await RunCommandShell ( others , cwd ) ;
57
+ }
58
+
59
+ async function RunCommandShell ( others : string [ ] , cwd : string ) {
60
+ const os = Deno . build . os ;
61
+ // console.log({ os });
62
+ const cmd = os === "windows" ? "powershell.exe" : "bash" ;
63
+
58
64
const args = os === "windows"
59
65
? [
60
66
"-command" ,
@@ -64,78 +70,47 @@ async function RunXmakeConfig(file: string, toolchain: string, sdk: string) {
64
70
"-c" ,
65
71
others . join ( " && " ) ,
66
72
] ;
67
- const cwd = path . dirname ( file ) ;
73
+
68
74
console . log ( JSON . stringify ( { cmd, cwd, args } ) ) ;
69
75
const command = new Deno . Command ( cmd , { cwd : cwd , args } ) ;
70
76
71
77
const { success, stderr, stdout, code } = await command . output ( ) ;
72
- console . log ( new TextDecoder ( ) . decode ( stdout ) ) ;
73
- console . error ( new TextDecoder ( ) . decode ( stderr ) ) ;
78
+ const decoded = {
79
+ stdout : new TextDecoder ( ) . decode ( stdout ) ,
80
+ stderr : new TextDecoder ( ) . decode ( stderr ) ,
81
+ } ;
82
+ console . log ( decoded . stdout ) ;
83
+ console . error ( decoded . stderr ) ;
74
84
console . log ( { success, code } ) ;
75
85
// await writeAll(Deno.stdout, stdout);
76
86
//await writeAll(Deno.stderr, stderr);
77
- assertEquals ( success , true ) ;
78
- assertEquals ( code , 0 ) ;
87
+ try {
88
+ assertEquals ( success , true ) ;
89
+ assertEquals ( code , 0 ) ;
90
+ } catch ( error ) {
91
+ Object . assign ( error , { success, code, ...decoded } ) ;
92
+ throw error ;
93
+ }
79
94
}
80
95
81
96
async function RunXmakeBuild ( file : string ) {
82
- const os = Deno . build . os ;
97
+ const cwd = path . dirname ( file ) ;
98
+
83
99
console . log ( { file } ) ;
84
100
// console.log({ os });
85
- const cmd = os === "windows" ? "powershell.exe" : "bash" ;
101
+
86
102
const others = [
87
103
` xmake build -v -y -w test` ,
88
104
] ;
89
- const args = os === "windows"
90
- ? [
91
- "-command" ,
92
- others . join ( " \n " ) ,
93
- ]
94
- : [
95
- "-c" ,
96
- others . join ( " && " ) ,
97
- ] ;
98
- const cwd = path . dirname ( file ) ;
99
- console . log ( JSON . stringify ( { cmd, cwd, args } ) ) ;
100
- const command = new Deno . Command ( cmd , { cwd : cwd , args } ) ;
101
-
102
- const { success, stderr, stdout, code } = await command . output ( ) ;
103
- console . log ( new TextDecoder ( ) . decode ( stdout ) ) ;
104
- console . error ( new TextDecoder ( ) . decode ( stderr ) ) ;
105
- console . log ( { success, code } ) ;
106
- // await writeAll(Deno.stdout, stdout);
107
- //await writeAll(Deno.stderr, stderr);
108
- assertEquals ( success , true ) ;
109
- assertEquals ( code , 0 ) ;
105
+ await RunCommandShell ( others , cwd ) ;
110
106
}
111
107
112
108
async function RunXmakeTest ( file : string ) {
113
- const os = Deno . build . os ;
114
109
console . log ( { file } ) ;
115
110
// console.log({ os });
116
- const cmd = os === "windows" ? "powershell.exe" : "bash" ;
117
111
const others = [
118
112
` xmake run -v test` ,
119
113
] ;
120
- const args = os === "windows"
121
- ? [
122
- "-command" ,
123
- others . join ( " \n " ) ,
124
- ]
125
- : [
126
- "-c" ,
127
- others . join ( " && " ) ,
128
- ] ;
129
114
const cwd = path . dirname ( file ) ;
130
- console . log ( JSON . stringify ( { cmd, cwd, args } ) ) ;
131
- const command = new Deno . Command ( cmd , { cwd : cwd , args } ) ;
132
-
133
- const { success, stderr, stdout, code } = await command . output ( ) ;
134
- console . log ( new TextDecoder ( ) . decode ( stdout ) ) ;
135
- console . error ( new TextDecoder ( ) . decode ( stderr ) ) ;
136
- console . log ( { success, code } ) ;
137
- // await writeAll(Deno.stdout, stdout);
138
- //await writeAll(Deno.stderr, stderr);
139
- assertEquals ( success , true ) ;
140
- assertEquals ( code , 0 ) ;
115
+ await RunCommandShell ( others , cwd ) ;
141
116
}
0 commit comments