Skip to content
This repository has been archived by the owner on Feb 1, 2025. It is now read-only.

Commit

Permalink
fix: search windows apps path (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy authored Apr 7, 2023
1 parent dbf319f commit 7019abb
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions find_ecsact_cli/find_ecsact_cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,46 @@ result::find_ecsact_cli ecsact::rtb::find_ecsact_cli(
auto ecsact_cli_from_path = bp::search_path(search_exe);
if(!ecsact_cli_from_path.empty()) {
path = ecsact_cli_from_path.string();
} else {
#ifdef _WIN32
// boost search_path does not find WindowsApps
auto local_app_data = std::getenv("LOCALAPPDATA");
if(local_app_data != nullptr) {
auto windows_apps_dir =
fs::path(std::string(local_app_data)) / "Microsoft" / "WindowsApps";

path = (windows_apps_dir / "ecsact.exe").string();
}
#endif
}
}

if(!path.empty()) {
options.reporter.report(ecsact_rtb::info_message{
.content = "Using Ecsact CLI: "s + path,
});
auto ec = boost::system::error_code{};
auto stdout_stream = bp::ipstream{};
auto ecsact_proc = bp::child(
bp::exe(path),
bp::args({"--version"}),
bp::std_out > stdout_stream
);

auto ecsact_version = std::string{};
std::getline(stdout_stream, ecsact_version);

ecsact_proc.wait();

if(ecsact_proc.exit_code() == 0 && !ecsact_version.empty()) {
options.reporter.report(ecsact_rtb::info_message{
.content = "Using Ecsact CLI (" + ecsact_version + "): "s + path,
});
} else {
options.reporter.report(ecsact_rtb::error_message{
.content = "ecsact --version exited with code " +
std::to_string(ecsact_proc.exit_code()),
});

path = "";
}
}

return {
Expand Down

0 comments on commit 7019abb

Please sign in to comment.