diff --git a/src/main/java/org/ballerinalang/command/cmd/PullCommand.java b/src/main/java/org/ballerinalang/command/cmd/PullCommand.java index 627467e1..4ef2f244 100644 --- a/src/main/java/org/ballerinalang/command/cmd/PullCommand.java +++ b/src/main/java/org/ballerinalang/command/cmd/PullCommand.java @@ -65,11 +65,6 @@ public void execute() { PrintStream printStream = getPrintStream(); String distribution = pullCommands.get(0); - if (!testFlag) { - // Check and update the tool if any latest version available - ToolUtil.updateTool(printStream); - } - // To handle bal dist pull latest if (distribution.equals(ToolUtil.LATEST_PULL_INPUT)) { printStream.println("Fetching the latest distribution from the remote server..."); diff --git a/src/main/java/org/ballerinalang/command/util/ToolUtil.java b/src/main/java/org/ballerinalang/command/util/ToolUtil.java index 83a6af5f..40017d9d 100644 --- a/src/main/java/org/ballerinalang/command/util/ToolUtil.java +++ b/src/main/java/org/ballerinalang/command/util/ToolUtil.java @@ -443,6 +443,9 @@ public static boolean downloadDistribution(PrintStream printStream, String distr conn.setRequestProperty("testMode", "true"); } if (conn.getResponseCode() == 302) { + if (!testMode) { + ToolUtil.updateTool(printStream); + } printStream.println("Fetching the '" + distribution + "' distribution from the remote server..."); String newUrl = conn.getHeaderField("Location"); conn = (HttpURLConnection) new URL(newUrl).openConnection(); @@ -451,6 +454,9 @@ public static boolean downloadDistribution(PrintStream printStream, String distr ToolUtil.getDependency(printStream, distribution, distributionType, distributionVersion); return false; } else if (conn.getResponseCode() == 200) { + if (!testMode) { + ToolUtil.updateTool(printStream); + } printStream.println("Fetching the '" + distribution + "' distribution from the remote server..."); ToolUtil.downloadAndSetupDist(printStream, conn, distribution); ToolUtil.getDependency(printStream, distribution, distributionType, distributionVersion); @@ -459,6 +465,9 @@ public static boolean downloadDistribution(PrintStream printStream, String distr throw ErrorUtil.createDistributionNotFoundException(distribution); } } else { + if (!testMode) { + ToolUtil.updateTool(printStream); + } printStream.println("'" + distribution + "' is already available locally"); return true; }