Explorar el Código

Fix os_exec_win

luboslenco hace 1 mes
padre
commit
5759832a7b
Se han modificado 2 ficheros con 8 adiciones y 3 borrados
  1. 7 1
      base/tools/amake/main.c
  2. 1 2
      base/tools/make.js

+ 7 - 1
base/tools/amake/main.c

@@ -73,11 +73,17 @@ static JSValue js_os_exec_win(JSContext *ctx, JSValue this_val, int argc, JSValu
 
 
     CloseHandle(hReadPipe);
     CloseHandle(hReadPipe);
     WaitForSingleObject(pi.hProcess, INFINITE);
     WaitForSingleObject(pi.hProcess, INFINITE);
+    DWORD exit_code;
+    GetExitCodeProcess(pi.hProcess, &exit_code);
     CloseHandle(pi.hProcess);
     CloseHandle(pi.hProcess);
     CloseHandle(pi.hThread);
     CloseHandle(pi.hThread);
 
 
     printf("%s", buf);
     printf("%s", buf);
-    return JS_NewString(ctx, buf);
+
+    JSValue result = JS_NewObject(ctx);
+    JS_SetPropertyStr(ctx, result, "stdout", JS_NewString(ctx, buf));
+    JS_SetPropertyStr(ctx, result, "status", JS_NewInt32(ctx, (int32_t)exit_code));
+    return result;
 }
 }
 
 
 #endif
 #endif

+ 1 - 2
base/tools/make.js

@@ -135,8 +135,7 @@ function os_exec(exe, params = [], ops = {}) {
 	let res = { status: 0 };
 	let res = { status: 0 };
 
 
 	if (os_platform() === "win32") {
 	if (os_platform() === "win32") {
-		res.stdout = amake.os_exec_win(params, ops);
-		res.status = 0;
+		res = amake.os_exec_win(params, ops); // { status, stdout }
 	}
 	}
 	else {
 	else {
 		res.status = os.exec(params, ops);
 		res.status = os.exec(params, ops);