src/extensions/default/AutoUpdate/main.js
function initiateUpdateProcess(formattedInstallerPath, formattedLogFilePath, installStatusFilePath) {

        // Get additional update parameters on Mac : installDir, appName, and updateDir
        function getAdditionalParams() {
            var retval = {};
            var installDir = FileUtils.getNativeBracketsDirectoryPath();

            if (installDir) {
                var appPath = installDir.split("/Contents/www")[0];
                installDir = appPath.substr(0, appPath.lastIndexOf('/'));
                var appName = appPath.substr(appPath.lastIndexOf('/') + 1);

                retval = {
                    installDir: installDir,
                    appName: appName,
                    updateDir: updateDir
                };
            }
            return retval;
        }

        // Update function, to carry out app update
        var updateFn = function () {
            var infoObj = {
                installerPath: formattedInstallerPath,
                logFilePath: formattedLogFilePath,
                installStatusFilePath: installStatusFilePath
            };

            if (brackets.platform === "mac") {
                var additionalParams = getAdditionalParams(),
                    key;

                for (key in additionalParams) {
                    if (additionalParams.hasOwnProperty(key)) {
                        infoObj[key] = additionalParams[key];
                    }
                }
            }

            // Set update parameters for app update
            if (brackets.app.setUpdateParams) {
                brackets.app.setUpdateParams(JSON.stringify(infoObj), function (err) {
                    if (err) {
                        resetStateInFailure("AutoUpdate : Update parameters could not be set for the installer. Error encountered: " + err);
                    } else {
                        setAppQuitHandler();
                        CommandManager.execute(Commands.FILE_QUIT);
                    }
                });
            } else {
                resetStateInFailure("AutoUpdate : setUpdateParams could not be found in shell");
            }
        };
        setUpdateStateInJSON('updateInitiatedInPrevSession', true)
            .done(updateFn);
    }
function initiateUpdateProcess(formattedInstallerPath, formattedLogFilePath, installStatusFilePath) {

        // Get additional update parameters on Mac : installDir, appName, and updateDir
        function getAdditionalParams() {
            var retval = {};
            var installDir = FileUtils.getNativeBracketsDirectoryPath();

            if (installDir) {
                var appPath = installDir.split("/Contents/www")[0];
                installDir = appPath.substr(0, appPath.lastIndexOf('/'));
                var appName = appPath.substr(appPath.lastIndexOf('/') + 1);

                retval = {
                    installDir: installDir,
                    appName: appName,
                    updateDir: updateDir
                };
            }
            return retval;
        }

        // Update function, to carry out app update
        var updateFn = function () {
            var infoObj = {
                installerPath: formattedInstallerPath,
                logFilePath: formattedLogFilePath,
                installStatusFilePath: installStatusFilePath
            };

            if (brackets.platform === "mac") {
                var additionalParams = getAdditionalParams(),
                    key;

                for (key in additionalParams) {
                    if (additionalParams.hasOwnProperty(key)) {
                        infoObj[key] = additionalParams[key];
                    }
                }
            }

            // Set update parameters for app update
            if (brackets.app.setUpdateParams) {
                brackets.app.setUpdateParams(JSON.stringify(infoObj), function (err) {
                    if (err) {
                        resetStateInFailure("AutoUpdate : Update parameters could not be set for the installer. Error encountered: " + err);
                    } else {
                        setAppQuitHandler();
                        CommandManager.execute(Commands.FILE_QUIT);
                    }
                });
            } else {
                resetStateInFailure("AutoUpdate : setUpdateParams could not be found in shell");
            }
        };
        setUpdateStateInJSON('updateInitiatedInPrevSession', true)
            .done(updateFn);
    }
function initiateUpdateProcess ( formattedInstallerPath , formattedLogFilePath , installStatusFilePath ) { // Get additional update parameters on Mac : installDir, appName, and updateDir function getAdditionalParams ( ) { var retval = { } ; var installDir = FileUtils . getNativeBracketsDirectoryPath ( ) ; if ( installDir ) { var appPath = installDir . split ( "/Contents/www" ) [ 0 ] ; installDir = appPath . substr ( 0 , appPath . lastIndexOf ( '/' ) ) ; var appName = appPath . substr ( appPath . lastIndexOf ( '/' ) + 1 ) ; retval = { installDir : installDir , appName : appName , updateDir : updateDir } ; } return retval ; } // Update function, to carry out app update var updateFn = function ( ) { var infoObj = { installerPath : formattedInstallerPath , logFilePath : formattedLogFilePath , installStatusFilePath : installStatusFilePath } ; if ( brackets . platform === "mac" ) { var additionalParams = getAdditionalParams ( ) , key ; for ( key in additionalParams ) { if ( additionalParams . hasOwnProperty ( key ) ) { infoObj [ key ] = additionalParams [ key ] ; } } } // Set update parameters for app update if ( brackets . app . setUpdateParams ) { brackets . app . setUpdateParams ( JSON . stringify ( infoObj ) , function ( err ) { if ( err ) { resetStateInFailure ( "AutoUpdate : Update parameters could not be set for the installer. Error encountered: " + err ) ; } else { setAppQuitHandler ( ) ; CommandManager . execute ( Commands . FILE_QUIT ) ; } } ) ; } else { resetStateInFailure ( "AutoUpdate : setUpdateParams could not be found in shell" ) ; } } ; setUpdateStateInJSON ( 'updateInitiatedInPrevSession' , true ) . done ( updateFn ) ; }
Initiates the update process, when user clicks UpdateNow in the update popup
@param {string} formattedInstallerPath - formatted path to the latest installer
@param {string} formattedLogFilePath  - formatted path to the installer log file
@param {string} installStatusFilePath  -  path to the install status log file
Initiates the update process when user clicks UpdateNow in the update popup