Skip to content

Commit

Permalink
fix: default cargo manifest directory to pwd
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Nov 4, 2023
1 parent ac21ff1 commit 575b43b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/smartdeploy-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use std::path::{Path, PathBuf};

use loam_build::get_target_dir;



#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error(transparent)]
Expand All @@ -12,7 +10,6 @@ pub enum Error {
MissingContractId(String),
}


pub fn wasm_location(name: &str, out_dir: Option<&Path>) -> Result<PathBuf, Error> {
let out_dir = if let Some(out_dir) = out_dir {
out_dir.to_path_buf()
Expand All @@ -26,13 +23,16 @@ pub fn wasm_location(name: &str, out_dir: Option<&Path>) -> Result<PathBuf, Erro

pub fn contract_id(name: &str, out_dir: Option<&Path>) -> Result<String, Error> {
let wasm = wasm_location(name, out_dir)?;
let parent = wasm.parent().ok_or_else(|| Error::MissingContractId(name.to_owned()))?;
let parent = wasm
.parent()
.ok_or_else(|| Error::MissingContractId(name.to_owned()))?;
let id_file = parent.join("contract_id.txt");
std::fs::read_to_string(id_file).map_err(|_| Error::MissingContractId(name.to_owned()))
}

fn manifest() -> PathBuf {
std::path::PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("Cargo.toml")
std::path::PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".to_owned()))
.join("Cargo.toml")
}

pub fn target_dir() -> Result<PathBuf, Error> {
Expand Down

0 comments on commit 575b43b

Please sign in to comment.