diff --git a/src/extensions/default/AutoUpdate/main.js b/src/extensions/default/AutoUpdate/main.js index a4fa83f1411..0f0d4f41bf7 100644 --- a/src/extensions/default/AutoUpdate/main.js +++ b/src/extensions/default/AutoUpdate/main.js @@ -329,27 +329,6 @@ define(function (require, exports, module) { } - /** - * Generates the extension for installer file, based on platform - * @returns {string} - OS - current OS } - */ - function getPlatformInfo() { - var OS = ""; - - if (/Windows|Win32|WOW64|Win64/.test(window.navigator.userAgent)) { - OS = "WIN"; - } else if (/Mac/.test(window.navigator.userAgent)) { - OS = "OSX"; - } else if (/Linux|X11/.test(window.navigator.userAgent)) { - OS = "LINUX32"; - if (/x86_64/.test(window.navigator.appVersion + window.navigator.userAgent)) { - OS = "LINUX64"; - } - } - - return OS; - } - /** * Initializes the state for AutoUpdate process * @returns {$.Deferred} - a jquery promise, @@ -466,7 +445,7 @@ define(function (require, exports, module) { console.warn("AutoUpdate : updates information not available."); return; } - var OS = getPlatformInfo(), + var OS = brackets.getPlatformInfo(), checksum, downloadURL, installerName, diff --git a/src/utils/Global.js b/src/utils/Global.js index 76c85cfdf1d..69a9189799c 100644 --- a/src/utils/Global.js +++ b/src/utils/Global.js @@ -83,6 +83,24 @@ define(function (require, exports, module) { global.brackets.platform = "win"; } + // Expose platform info for build applicability consumption + global.brackets.getPlatformInfo = function () { + var OS = ""; + + if (/Windows|Win32|WOW64|Win64/.test(window.navigator.userAgent)) { + OS = "WIN"; + } else if (/Mac/.test(window.navigator.userAgent)) { + OS = "OSX"; + } else if (/Linux|X11/.test(window.navigator.userAgent)) { + OS = "LINUX32"; + if (/x86_64/.test(window.navigator.appVersion + window.navigator.userAgent)) { + OS = "LINUX64"; + } + } + + return OS; + }; + global.brackets.inBrowser = !global.brackets.hasOwnProperty("fs"); // Are we in a desktop shell with a native menu bar? diff --git a/src/utils/UpdateNotification.js b/src/utils/UpdateNotification.js index dd012e4027c..cdd05f6067e 100644 --- a/src/utils/UpdateNotification.js +++ b/src/utils/UpdateNotification.js @@ -261,6 +261,13 @@ define(function (require, exports, module) { return result.promise(); } + /** + * Checks whether a build is applicable to the current platform. + */ + function _checkBuildApplicability(buildInfo) { + return !buildInfo.platforms || buildInfo.platforms[brackets.getPlatformInfo()]; + } + /** * Return a new array of version information that is newer than "buildNumber". * Returns null if there is no new version information. @@ -270,20 +277,23 @@ define(function (require, exports, module) { // should get through the search quickly. var lastIndex = 0; var len = versionInfo.length; + var versionEntry; + var validBuildEntries; while (lastIndex < len) { - if (versionInfo[lastIndex].buildNumber <= buildNumber) { + versionEntry = versionInfo[lastIndex]; + if (versionEntry.buildNumber <= buildNumber) { break; } lastIndex++; } if (lastIndex > 0) { - return versionInfo.slice(0, lastIndex); + // Filter recent update entries based on applicability to current platform + validBuildEntries = versionInfo.slice(0, lastIndex).filter(_checkBuildApplicability); } - // No new version info - return null; + return validBuildEntries; } /** @@ -446,7 +456,7 @@ define(function (require, exports, module) { return; } - if (allUpdates) { + if (allUpdates && allUpdates.length > 0) { // Always show the "update available" icon if any updates are available var $updateNotification = $("#update-notification");