From 1ffadce5a82952032447f11efff8b5a1407e5777 Mon Sep 17 00:00:00 2001 From: suragch Date: Thu, 30 May 2024 09:59:19 +0800 Subject: [PATCH] static shock cli: handle socket exceptions when checking for pub version --- packages/static_shock_cli/lib/src/version_check.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/static_shock_cli/lib/src/version_check.dart b/packages/static_shock_cli/lib/src/version_check.dart index ac0cda6..14eb35a 100644 --- a/packages/static_shock_cli/lib/src/version_check.dart +++ b/packages/static_shock_cli/lib/src/version_check.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:args/command_runner.dart'; import 'package:mason_logger/mason_logger.dart'; import 'package:pub_semver/pub_semver.dart'; @@ -20,8 +22,13 @@ mixin PubVersionCheck on Command { @override Future run() async { - final isUpToDate = await StaticShockCliVersion.isAtLeastUpToDateWithPub(); - if (isUpToDate) { + try { + final isUpToDate = await StaticShockCliVersion.isAtLeastUpToDateWithPub(); + if (isUpToDate) { + return; + } + } on SocketException { + log.warn('Unable to reach pub.dev. Skipping version check.'); return; }