[Refactor] Use Lua script for C2S_BUILD_FILE handling.

This commit is contained in:
Ritchie Cunningham 2025-11-01 18:06:54 +00:00
parent ea6853f037
commit 785e6ddc38

View File

@ -222,14 +222,13 @@ void NetworkManager::on_message(std::shared_ptr<net::TcpConnection> connection,
/* Save the file to ensure the VFS is up to date. */ /* Save the file to ensure the VFS is up to date. */
session->write_file(path, content); session->write_file(path, content);
/* The 'build.lua' script is just a wrapper around 'api::create_executable'. */ /* Execute the build command via the session. */
std::string exec_path = path; std::string response = session->process_command("build " + path);
size_t dot_pos = exec_path.rfind(".lua"); /* Send response back to client. */
if(dot_pos != std::string::npos) { std::string new_prompt = get_full_path(session->get_current_dir());
exec_path.erase(dot_pos); response += "\n" + new_prompt;
} connection->send(net_protocol::build_message(net_protocol::Opcode::S2C_COMMAND_RESPONSE,
/* The api function returns an error string, but we'll ignore it here for now. */ {args[0], response}));
api::create_executable(*session, exec_path, content);
} }
} }
break; break;