diff --git a/astronaut/freshnaut b/astronaut/freshnaut index d2e630a..a822eed 100755 --- a/astronaut/freshnaut +++ b/astronaut/freshnaut @@ -137,7 +137,7 @@ function get_available_versions(satellite) print("\x1B[1K\rWARNING: " .. satellite .. ": Current version isn't available") end - return versions + return versions, update_url end function check_new_versions(satellite, version_file_path) @@ -147,7 +147,7 @@ function check_new_versions(satellite, version_file_path) -- Uses version_file_path to know where to store all known versions. --]]-- - local versions = get_available_versions(satellite) + local versions, update_url = get_available_versions(satellite) if not versions then return end @@ -166,15 +166,25 @@ function check_new_versions(satellite, version_file_path) assert(version_file, "Failed to create " .. version_file_path) end - for version, _ in spairs(versions) do - if old_versions then + local new_versions = {} + if old_versions then + for version, _ in spairs(versions) do if not old_versions[version] then - print("\x1B[1K\r" .. satellite .. ": " .. version) - version_file:write(version .. "\n") + table.insert(new_versions, version) end - else - print("\x1B[1K\r" .. satellite .. ": " .. version) + end + else + for version, _ in spairs(versions) do + table.insert(new_versions, version) + end + end + + if #new_versions > 0 then + print("\x1B[1K\r" .. satellite .. ": From '" .. update_url .. "'") + + for _, version in ipairs(new_versions) do version_file:write(version .. "\n") + print("\x1B[1K\r" .. satellite .. ": " .. version) end end