Skip to content

Commit

Permalink
fix(turborepo): Run update notifier on turbo that is actually executed (
Browse files Browse the repository at this point in the history
#3190)

To avoid running the update notifier twice, we delay running it until
the shim decides between executing local turbo or current turbo. At that
point, we check either the local turbo version or the current turbo
version and run the update notifier.

Co-authored-by: Thomas Knickman <tom.knickman@vercel.com>
  • Loading branch information
NicholasLYang and tknickman committed Jan 6, 2023
1 parent e966c0d commit 03d094f
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 97 deletions.
11 changes: 9 additions & 2 deletions crates/turbo-updater/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ pub fn check_for_updates(
current_version: &str,
timeout: Option<Duration>,
interval: Option<Duration>,
is_global_turbo: bool,
) -> Result<(), UpdateNotifierError> {
// bail early if the user has disabled update notifications
if should_skip_notification() {
Expand All @@ -128,6 +129,13 @@ pub fn check_for_updates(
.interval(interval);
if let Ok(Some(version)) = informer.check_version() {
let latest_version = version.to_string();
// TODO: make this package manager aware
let update_cmd = if is_global_turbo {
"npm i -g turbo".cyan().bold()
} else {
"npm i turbo".cyan().bold()
};

let msg = format!(
"
Update available {version_prefix}{current_version} ≫ {latest_version}
Expand All @@ -138,8 +146,7 @@ pub fn check_for_updates(
current_version = current_version.dimmed(),
latest_version = latest_version.green().bold(),
github_repo = github_repo,
// TODO: make this package manager aware
update_cmd = "npm i -g turbo".cyan().bold(),
update_cmd = update_cmd
);

if let Some(footer) = footer {
Expand Down

0 comments on commit 03d094f

Please sign in to comment.