import fs = require ( 'fs-promise' ) ; import path = require ( 'path' ) ; import vscode = require ( 'vscode' ) ; import file = require ( '../workspace/jsonFile' ) ; import Promise = require ( 'bluebird' ) ; export class ProjectSettings { id : string ; projectName : string ; instanceUrl : string ; private static _instances : { [ projectPath ] : ProjectSettings ; } = { } ; static getProjectSettings ( projectPath ? ) { projectPath = workspaceRootIfBlank ( projectPath ) ; if ( projectPath && ! ProjectSettings . _instances [ projectPath ] ) { let settingsPath = buildSettingsPath ( projectPath ) ; console . info ( `Retrieving settings at path:  ${ settingsPath }` ) ; ProjectSettings . _instances [ projectPath ] = file . open ( settingsPath ) ; } return ProjectSettings . _instances [ projectPath ] ; } static hasProjectSettings ( projectPath ? ) { projectPath = workspaceRootIfBlank ( projectPath ) ; if ( ! ProjectSettings . _instances [ projectPath ] ) { ProjectSettings . getProjectSettings ( projectPath ) ; } return ProjectSettings . _instances [ projectPath ] !== null ; } } function workspaceRootIfBlank ( projectPath ? ) { return projectPath || vscode . workspace . rootPath ; } function buildSettingsPath ( projectPath ) { return path . join ( projectPath , 'config' , '.settings' ) ; }