'use strict' ; import Promise = require ( 'bluebird' ) ; import { window , QuickPickItem , commands , Uri } from 'vscode' ; import { promiseList , projectDirectory } from '../../src/workspace/projectList' ; export interface projectQuickPickItem extends QuickPickItem { path : string ; } export function showProjectQuickPick ( ) { return promiseList ( ) . then ( ( projects ) => { return Promise . map ( projects , buildQuickPickProject ) . then ( window . showQuickPick ) ; } ) ; } function buildQuickPickProject ( project ) { return { description : project . workspace , detail : project . path , label : project . name , path : project . path } ; } export function openProject ( projectItem ) { if ( projectItem ) { let projectUri = Uri . parse ( projectItem . path ) ; return commands . executeCommand ( 'vscode.openFolder' , projectUri ) . then ( null , console . error ) ; } else { console . warn ( 'MavensMate: No project selected' ) ; return ; } } export function showProjectListAndOpen ( ) { return showProjectQuickPick ( ) . then ( openProject ) ; }