Skip to content

Commit

Permalink
Improve workdir for support more cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Dec 3, 2021
1 parent a2864d1 commit df52641
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description = "Support for rust-i18n crate."
edition = "2021"
license = "MIT"
name = "rust-i18n-support"
version = "0.1.0"
version = "0.1.1"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
9 changes: 8 additions & 1 deletion crates/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/// // => "/Users/jason/work/rust-i18n"
/// ```
pub fn workdir(dest: &str) -> String {
let seperator = regex::Regex::new(r"(/target/([\w]+)/build/)|(\\target\\([\w]+)\\build\\)")
let seperator = regex::Regex::new(r"(/target/(.+?)/build/)|(\\target\\(.+?)\\build\\)")
.expect("Invalid regex");
let parts = seperator.split(dest).collect::<Vec<_>>();

Expand Down Expand Up @@ -56,5 +56,12 @@ mod tests {
r#"/Users/jason/work/rust-i18n/target/foo/build/rust-i18n-d1612e30e02f745c/out"#
)
);

assert_eq!(
r"/opt/rustwide",
crate::workdir(
r"/opt/rustwide/target/x86_64-unknown-linux-gnu/debug/build/rust-i18n-c1b1cee86c09c9f1/out"
)
)
}
}

0 comments on commit df52641

Please sign in to comment.