安装输出改为实时输出

This commit is contained in:
a158
2026-05-07 23:52:49 +08:00
parent bf65dbb9f7
commit 897cf54c9f

View File

@@ -43,9 +43,10 @@ std::pair<int,std::string> execute_command(const std::string& command){
throw std::runtime_error("popen() failed!");
}
// Read the output a line at a time - output it.
// Read and tee to stdout so logs appear as the subprocess writes (not only after exit).
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
result += buffer.data();
std::cout << buffer.data() << std::flush;
}
// Get the return code
@@ -264,7 +265,7 @@ void fastweb::uninstall_module(std::string ini_filepath, std::string name)
else
{
std::cout<<"卸载失败:"<<std::endl;
std::cout<<err<<std::endl;
// std::cout<<err<<std::endl;
}
}
#endif
@@ -387,8 +388,8 @@ void fastweb::install_module_linux(fastweb::module_info info)
if(code != 0)
{
std::cerr<<"安装失败:"<<std::endl;
std::cerr<<cmd<<std::endl;
std::cerr<<err<<std::endl;
// std::cerr<<cmd<<std::endl;
// std::cerr<<err<<std::endl;
}
else
{
@@ -405,8 +406,8 @@ void fastweb::install_module_linux(fastweb::module_info info)
if(code != 0)
{
std::cerr<<"克隆仓库失败:"<<std::endl;
std::cerr << cmd << std::endl;
std::cerr << result << std::endl;
// std::cerr << cmd << std::endl;
// std::cerr << result << std::endl;
return;
}
@@ -417,8 +418,8 @@ void fastweb::install_module_linux(fastweb::module_info info)
if(code2 != 0)
{
std::cerr<<"执行安装命令失败:"<<std::endl;
std::cerr << cmd << std::endl;
std::cerr << result2 << std::endl;
// std::cerr << cmd << std::endl;
// std::cerr << result2 << std::endl;
return;
}
@@ -444,7 +445,7 @@ void fastweb::install_module_linux(fastweb::module_info info)
else
{
std::cout<<"安装失败:"<<std::endl;
std::cout<<err<<std::endl;
// std::cout<<err<<std::endl;
}
}