{"size": 690, "ext": "js", "max_stars_repo_path": "getEnv.js", "max_stars_repo_name": "KevinJMcGrath/Gamma-v3-Vue", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "getEnv.js", "max_issues_repo_name": "KevinJMcGrath/Gamma-v3-Vue", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "getEnv.js", "max_forks_repo_name": "KevinJMcGrath/Gamma-v3-Vue", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.0, "max_line_length": 87, "alphanum_fraction": 0.6608695652}
//http://gunargessner.com/gcloud-env-vars/
'use strict'

const fs = require('fs');


const dotEnvExists = fs.existsSync('.env');
if(dotEnvExists)
{
	console.log('getEnv.js: .env exists - probably running dev');		
}
else
{
	const gcs = require('@google-cloud/storage')();

	//Need to create a bucket called "envvars.<GCP_PROJECT>.gamma-self-service"
	const bucketName = 'envvars-gamma-${process.env.GCLOUD_PROJECT}';

	gcs
		.bucket(bucketName)
		.file('.env')
		.download({ destination: '.env'})
		.then(() => {
			console.info('getEnv.js: .env downloaded successfully');
		})
		.catch(e => {
			console.error('getEnv.js: There was an error - ${JSON.stringify(e, undefined, 2)}');
		});
}	
