src/project/ProjectManager.js
function _getFallbackProjectPath() {
        var fallbackPaths = [],
            recentProjects = PreferencesManager.getViewState("recentProjects") || [],
            deferred = new $.Deferred();

        // Build ordered fallback path array
        if (recentProjects.length > 1) {
            // *Most* recent project is the one that just failed to load, so use second most recent
            fallbackPaths.push(recentProjects[1]);
        }

        // Next is Getting Started project
        fallbackPaths.push(_getWelcomeProjectPath());

        // Helper func for Async.firstSequentially()
        function processItem(path) {
            var deferred = new $.Deferred(),
                fileEntry = FileSystem.getDirectoryForPath(path);

            fileEntry.exists(function (err, exists) {
                if (!err && exists) {
                    deferred.resolve();
                } else {
                    deferred.reject();
                }
            });

            return deferred.promise();
        }

        // Find first path that exists
        Async.firstSequentially(fallbackPaths, processItem)
            .done(function (fallbackPath) {
                deferred.resolve(fallbackPath);
            })
            .fail(function () {
                // Last resort is Brackets source folder which is guaranteed to exist
                deferred.resolve(FileUtils.getNativeBracketsDirectoryPath());
            });

        return deferred.promise();
    }
function _getFallbackProjectPath() {
        var fallbackPaths = [],
            recentProjects = PreferencesManager.getViewState("recentProjects") || [],
            deferred = new $.Deferred();

        // Build ordered fallback path array
        if (recentProjects.length > 1) {
            // *Most* recent project is the one that just failed to load, so use second most recent
            fallbackPaths.push(recentProjects[1]);
        }

        // Next is Getting Started project
        fallbackPaths.push(_getWelcomeProjectPath());

        // Helper func for Async.firstSequentially()
        function processItem(path) {
            var deferred = new $.Deferred(),
                fileEntry = FileSystem.getDirectoryForPath(path);

            fileEntry.exists(function (err, exists) {
                if (!err && exists) {
                    deferred.resolve();
                } else {
                    deferred.reject();
                }
            });

            return deferred.promise();
        }

        // Find first path that exists
        Async.firstSequentially(fallbackPaths, processItem)
            .done(function (fallbackPath) {
                deferred.resolve(fallbackPath);
            })
            .fail(function () {
                // Last resort is Brackets source folder which is guaranteed to exist
                deferred.resolve(FileUtils.getNativeBracketsDirectoryPath());
            });

        return deferred.promise();
    }
function _getFallbackProjectPath ( ) { var fallbackPaths = [ ] , recentProjects = PreferencesManager . getViewState ( "recentProjects" ) || [ ] , deferred = new $ . Deferred ( ) ; // Build ordered fallback path array if ( recentProjects . length > 1 ) { // *Most* recent project is the one that just failed to load, so use second most recent fallbackPaths . push ( recentProjects [ 1 ] ) ; } // Next is Getting Started project fallbackPaths . push ( _getWelcomeProjectPath ( ) ) ; // Helper func for Async.firstSequentially() function processItem ( path ) { var deferred = new $ . Deferred ( ) , fileEntry = FileSystem . getDirectoryForPath ( path ) ; fileEntry . exists ( function ( err , exists ) { if ( ! err && exists ) { deferred . resolve ( ) ; } else { deferred . reject ( ) ; } } ) ; return deferred . promise ( ) ; } // Find first path that exists Async . firstSequentially ( fallbackPaths , processItem ) . done ( function ( fallbackPath ) { deferred . resolve ( fallbackPath ) ; } ) . fail ( function ( ) { // Last resort is Brackets source folder which is guaranteed to exist deferred . resolve ( FileUtils . getNativeBracketsDirectoryPath ( ) ) ; } ) ; return deferred . promise ( ) ; }
After failing to load a project, this function determines which project path to fallback to.
@return {$.Promise} Promise that resolves to a project path {string}
After failing to load a project this function determines which project path to fallback to .