Skip to content

Commit

Permalink
update hmm.json when doing hmm-rs haxelib
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjamuffin99 committed Jan 3, 2025
1 parent 212ad59 commit 78a593b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/commands/haxelib_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use reqwest::blocking::Client;

use crate::{
commands,
hmm::haxelib::{self, Haxelib, HaxelibType},
hmm::{
self,
haxelib::{self, Haxelib, HaxelibType},
},
};

pub fn install_haxelib(name: &str, version: &Option<String>) -> Result<()> {
Expand Down Expand Up @@ -50,5 +53,8 @@ pub fn install_haxelib(name: &str, version: &Option<String>) -> Result<()> {
}
};
commands::install_command::install_from_haxelib(&haxelib_install)?;
let mut hmm_deps = hmm::json::read_json("./hmm.json")?;
hmm_deps.dependencies.push(haxelib_install);
hmm::json::save_json(hmm_deps, "./hmm.json")?;
Ok(())
}
2 changes: 1 addition & 1 deletion src/hmm/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::dependencies::Dependancies;
use anyhow::{Context, Result};

pub fn save_json(deps: Dependancies, path: &str) -> Result<()> {
println!("Saving to {}", path);
println!("{} saved/updated", path);
let j = serde_json::to_string_pretty(&deps)?;
let mut file = File::create(path)?;
file.write_all(j.as_bytes())?;
Expand Down
12 changes: 9 additions & 3 deletions tests/samples/hmm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@
{
"name": "lime",
"type": "git",
"dir": null,
"ref": "9478698b35fb518e98b5189376226f384ccc256a",
"dir": null,
"url": "https://github.com/FunkinCrew/lime"
},
{
"name": "hxcpp",
"type": "git",
"dir": null,
"ref": "v4.3.68",
"dir": null,
"url": "https://github.com/HaxeFoundation/hxcpp"
},
{
"name": "flixel",
"type": "haxelib",
"dir": null,
"version": "5.9.0"
}
]
}
}

0 comments on commit 78a593b

Please sign in to comment.