Skip to content

Commit

Permalink
misc: update how trampoline read it's metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
nichmor committed Oct 30, 2024
1 parent b294c9e commit 298fad9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions crates/pixi_trampoline/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ use std::os::unix::process::CommandExt;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};


// trampoline configuration folder name
pub const TRAMPOLINE_CONFIGURATION: &str = "trampoline_configuration";

#[derive(Deserialize, Debug)]
struct Metadata {
exe: String,
Expand All @@ -15,8 +19,11 @@ struct Metadata {
}

fn read_metadata(current_exe: &Path) -> Metadata {
// the metadata file is next to the current executable, under the name of exe + ".json"
let metadata_path = current_exe.with_extension("json");
// the metadata file is next to the current executable parent folder,
// under trampoline_configuration/current_exe_name.json
let exe_parent = current_exe.parent().expect("should have a parent");
let exe_name = current_exe.file_stem().expect("should have a file name");
let metadata_path = exe_parent.join(TRAMPOLINE_CONFIGURATION).join(exe_name).join(".json");
let metadata_file = File::open(metadata_path).unwrap();
let metadata: Metadata = serde_json::from_reader(metadata_file).unwrap();
metadata
Expand Down

0 comments on commit 298fad9

Please sign in to comment.