'use strict' ; import * as fs from 'fs-extra' ; import * as yaml from 'js-yaml' ; export class ConnectionProfileUtil { public static async readConnectionProfile ( connectionProfilePath ) { const connectionProfileContents = await fs . readFile ( connectionProfilePath , 'utf8' ) ; let connectionProfile ; if ( connectionProfilePath . endsWith ( '.json' ) ) { connectionProfile = JSON . parse ( connectionProfileContents ) ; } else if ( connectionProfilePath . endsWith ( '.yaml' ) || connectionProfilePath . endsWith ( '.yml' ) ) { connectionProfile = yaml . safeLoad ( connectionProfileContents ) ; } else { throw new Error ( 'Connection profile must be in JSON or yaml format' ) ; } return connectionProfile ; } }