Add step to update haxelib packages (#774)

This commit is contained in:
Andrea Tupini
2021-10-25 12:54:27 -06:00
committed by GitHub
parent 9023942a85
commit 6eb4cdd224
3 changed files with 26 additions and 0 deletions

View File

@@ -77,6 +77,30 @@ pub fn run_gem(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
command.check_run()
}
pub fn run_haxelib_update(ctx: &ExecutionContext) -> Result<()> {
let haxelib = utils::require("haxelib")?;
let haxelib_dir =
PathBuf::from(std::str::from_utf8(&Command::new(&haxelib).arg("config").output()?.stdout)?.trim()).require()?;
let directory_writable = tempfile_in(&haxelib_dir).is_ok();
debug!("{:?} writable: {}", haxelib_dir, directory_writable);
print_separator("haxelib");
let mut command = if directory_writable {
ctx.run_type().execute(&haxelib)
} else {
let mut c = ctx
.run_type()
.execute(ctx.sudo().as_ref().ok_or(TopgradeError::SudoRequired)?);
c.arg(&haxelib);
c
};
command.arg("update").check_run()
}
pub fn run_sheldon(ctx: &ExecutionContext) -> Result<()> {
let sheldon = utils::require("sheldon")?;