Skip to content

Commit

Permalink
Add helper for removing ANSI codes for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
schneems committed Oct 2, 2024
1 parent 695a8eb commit 6b253e8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions buildpacks/ruby/src/layers/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ where
}
}

/// Removes ANSI control characters from a string
#[cfg(test)]
pub(crate) fn strip_ansi(input: impl AsRef<str>) -> String {
let re = regex::Regex::new(r"\x1b\[[0-9;]*[a-zA-Z]").expect("Clippy checked");
re.replace_all(input.as_ref(), "").to_string()
}

/// Takes in a directory and returns a minimal build context for use in testing shared caching behavior
///
/// Intented only for use with this buildpack, but meant to be used by multiple layers to assert caching behavior.
Expand Down

0 comments on commit 6b253e8

Please sign in to comment.