Skip to content

Commit

Permalink
Improve formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasy-peak committed Sep 2, 2024
1 parent 3d0cefc commit 6ca977e
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void formatCode(const std::string& file, const std::string& content) {
char buffer[2048] = {};
std::string result;
char* clang_format_path = std::getenv("FRPC_CLANG_FORMAT");
auto command = fmt::format("{} {}", clang_format_path ? clang_format_path : "clang-format", file);
auto command = fmt::format("{} -i {}", clang_format_path ? clang_format_path : "clang-format", file);
spdlog::info("start format {}", command);
FILE* pipe = popen(command.c_str(), "r");
if (!pipe) {
Expand All @@ -234,12 +234,7 @@ void formatCode(const std::string& file, const std::string& content) {
pclose(pipe);
if (result.empty())
return;
std::ofstream write(file);
if (!write.is_open()) {
spdlog::error("open {} fail", file);
return;
}
write << result;
spdlog::info("result: {}", result);
}

auto sort(nlohmann::json json) {
Expand Down

0 comments on commit 6ca977e

Please sign in to comment.