Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create infra utils crate #2073

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"crates/blockifier",
"crates/blockifier_reexecution",
"crates/committer_cli",
"crates/infra_utils",
"crates/mempool_test_utils",
"crates/native_blockifier",
"crates/papyrus_base_layer",
Expand Down Expand Up @@ -131,6 +132,7 @@ http-body = "0.4.5"
human_bytes = "0.4.3"
hyper = "0.14"
indexmap = "2.1.0"
infra_utils = { path = "crates/infra_utils", version = "0.0.0" }
insta = "1.29.0"
integer-encoding = "3.0.4"
itertools = "0.12.1"
Expand Down
10 changes: 10 additions & 0 deletions crates/infra_utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "infra_utils"
version.workspace = true
edition.workspace = true
repository.workspace = true
license-file.workspace = true
description = "Infrastructure utility."

[lints]
workspace = true
1 change: 1 addition & 0 deletions crates/infra_utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod path;
1 change: 1 addition & 0 deletions crates/infra_utils/src/path.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO(Arni): Move the function get_absolute_path to this file.
3 changes: 2 additions & 1 deletion crates/starknet_sequencer_node/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ pub fn create_node_modules(
/// Returns the absolute path from the project root.
pub fn get_absolute_path(relative_path: &str) -> PathBuf {
let base_dir = env::var("CARGO_MANIFEST_DIR")
// Attempt to get the `CARGO_MANIFEST_DIR` environment variable and convert it to `PathBuf`. Ascend two directories ("../..") to get to the project root.
// Attempt to get the `CARGO_MANIFEST_DIR` environment variable and convert it to `PathBuf`.
// Ascend two directories ("../..") to get to the project root.
.map(|dir| PathBuf::from(dir).join("../.."))
// If `CARGO_MANIFEST_DIR` isn't set, fall back to the current working directory
.unwrap_or_else(|_| env::current_dir().expect("Failed to get current directory"));
Expand Down
Loading