mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 10:33:54 +00:00
feat(cli): check for updates in background (#15974)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
This commit is contained in:
parent
bfc1fb8d68
commit
a48d05fac7
4 changed files with 181 additions and 19 deletions
24
cli/main.rs
24
cli/main.rs
|
@ -807,6 +807,29 @@ async fn run_with_watch(flags: Flags, script: String) -> Result<i32, AnyError> {
|
|||
Ok(0)
|
||||
}
|
||||
|
||||
fn check_for_upgrades(cache_dir: PathBuf) {
|
||||
// Run a background task that checks for available upgrades. If an earlier
|
||||
// run of this background task found a new version of Deno, the new version
|
||||
// number (or commit hash for canary builds) is returned.
|
||||
let maybe_upgrade_version = tools::upgrade::check_for_upgrades(cache_dir);
|
||||
|
||||
// Print a message if an update is available, unless:
|
||||
// * stderr is not a tty
|
||||
// * we're already running the 'deno upgrade' command.
|
||||
if let Some(upgrade_version) = maybe_upgrade_version {
|
||||
if atty::is(atty::Stream::Stderr) {
|
||||
eprint!(
|
||||
"{} ",
|
||||
colors::green(format!("Deno {upgrade_version} has been released."))
|
||||
);
|
||||
eprintln!(
|
||||
"{}",
|
||||
colors::italic_gray("Run `deno upgrade` to install it.")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn run_command(
|
||||
flags: Flags,
|
||||
run_flags: RunFlags,
|
||||
|
@ -824,6 +847,7 @@ async fn run_command(
|
|||
// map specified and bare specifier is used on the command line - this should
|
||||
// probably call `ProcState::resolve` instead
|
||||
let ps = ProcState::build(flags).await?;
|
||||
check_for_upgrades(ps.dir.root.clone());
|
||||
let main_module = if NpmPackageReference::from_str(&run_flags.script).is_ok()
|
||||
{
|
||||
ModuleSpecifier::parse(&run_flags.script)?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue