src/project/ProjectManager.js
function openProject(path) {

        var result = new $.Deferred();

        // Confirm any unsaved changes first. We run the command in "prompt-only" mode, meaning it won't
        // actually close any documents even on success; we'll do that manually after the user also oks
        // the folder-browse dialog.
        CommandManager.execute(Commands.FILE_CLOSE_ALL, { promptOnly: true })
            .done(function () {
                if (path) {
                    // use specified path
                    _loadProject(path, false).then(result.resolve, result.reject);
                } else {
                    // Pop up a folder browse dialog
                    FileSystem.showOpenDialog(false, true, Strings.CHOOSE_FOLDER, model.projectRoot.fullPath, null, function (err, files) {
                        if (!err) {
                            // If length == 0, user canceled the dialog; length should never be > 1
                            if (files.length > 0) {
                                // Load the new project into the folder tree
                                _loadProject(files[0]).then(result.resolve, result.reject);
                            } else {
                                result.reject();
                            }
                        } else {
                            _showErrorDialog(ERR_TYPE_OPEN_DIALOG, null, err);
                            result.reject();
                        }
                    });
                }
            })
            .fail(function () {
                result.reject();
            });

        // if fail, don't open new project: user canceled (or we failed to save its unsaved changes)
        return result.promise();
    }
function openProject(path) {

        var result = new $.Deferred();

        // Confirm any unsaved changes first. We run the command in "prompt-only" mode, meaning it won't
        // actually close any documents even on success; we'll do that manually after the user also oks
        // the folder-browse dialog.
        CommandManager.execute(Commands.FILE_CLOSE_ALL, { promptOnly: true })
            .done(function () {
                if (path) {
                    // use specified path
                    _loadProject(path, false).then(result.resolve, result.reject);
                } else {
                    // Pop up a folder browse dialog
                    FileSystem.showOpenDialog(false, true, Strings.CHOOSE_FOLDER, model.projectRoot.fullPath, null, function (err, files) {
                        if (!err) {
                            // If length == 0, user canceled the dialog; length should never be > 1
                            if (files.length > 0) {
                                // Load the new project into the folder tree
                                _loadProject(files[0]).then(result.resolve, result.reject);
                            } else {
                                result.reject();
                            }
                        } else {
                            _showErrorDialog(ERR_TYPE_OPEN_DIALOG, null, err);
                            result.reject();
                        }
                    });
                }
            })
            .fail(function () {
                result.reject();
            });

        // if fail, don't open new project: user canceled (or we failed to save its unsaved changes)
        return result.promise();
    }
function openProject ( path ) { var result = new $ . Deferred ( ) ; // Confirm any unsaved changes first. We run the command in "prompt-only" mode, meaning it won't // actually close any documents even on success; we'll do that manually after the user also oks // the folder-browse dialog. CommandManager . execute ( Commands . FILE_CLOSE_ALL , { promptOnly : true } ) . done ( function ( ) { if ( path ) { // use specified path _loadProject ( path , false ) . then ( result . resolve , result . reject ) ; } else { // Pop up a folder browse dialog FileSystem . showOpenDialog ( false , true , Strings . CHOOSE_FOLDER , model . projectRoot . fullPath , null , function ( err , files ) { if ( ! err ) { // If length == 0, user canceled the dialog; length should never be > 1 if ( files . length > 0 ) { // Load the new project into the folder tree _loadProject ( files [ 0 ] ) . then ( result . resolve , result . reject ) ; } else { result . reject ( ) ; } } else { _showErrorDialog ( ERR_TYPE_OPEN_DIALOG , null , err ) ; result . reject ( ) ; } } ) ; } } ) . fail ( function ( ) { result . reject ( ) ; } ) ; // if fail, don't open new project: user canceled (or we failed to save its unsaved changes) return result . promise ( ) ; }
Open a new project. Currently, Brackets must always have a project open, so
this method handles both closing the current project and opening a new project.

@param {string=} path Optional absolute path to the root folder of the project.
If path is undefined or null, displays a dialog where the user can choose a
folder to load. If the user cancels the dialog, nothing more happens.
@return {$.Promise} A promise object that will be resolved when the
project is loaded and tree is rendered, or rejected if the project path
fails to load.
Open a new project . Currently Brackets must always have a project open so this method handles both closing the current project and opening a new project .