Skip to content

Commit

Permalink
Restore cargo-insta compat with older insta (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko authored Mar 3, 2024
1 parent 0d4bab1 commit 780c343
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,15 @@ impl ToolConfig {
}
let cfg = cfg.unwrap_or_else(|| Content::Map(Default::default()));

if let Ok("1") = env::var("INSTA_FORCE_UPDATE_SNAPSHOTS").as_deref() {
eprintln!("INSTA_FORCE_UPDATE_SNAPSHOTS is deprecated, use INSTA_FORCE_UPDATE");
env::set_var("INSTA_FORCE_UPDATE", "1");
// support for the deprecated environment variable. This is implemented in a way that
// cargo-insta can support older and newer insta versions alike. It will set both
// variables. However if only `INSTA_FORCE_UPDATE_SNAPSHOTS` is set, we will emit
// a deprecation warning.
if env::var("INSTA_FORCE_UPDATE").is_err() {
if let Ok("1") = env::var("INSTA_FORCE_UPDATE_SNAPSHOTS").as_deref() {
eprintln!("INSTA_FORCE_UPDATE_SNAPSHOTS is deprecated, use INSTA_FORCE_UPDATE");
env::set_var("INSTA_FORCE_UPDATE", "1");
}
}

Ok(ToolConfig {
Expand Down

0 comments on commit 780c343

Please sign in to comment.