-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.js
More file actions
25 lines (21 loc) · 671 Bytes
/
env.js
File metadata and controls
25 lines (21 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use strict'
const fs = require('fs')
const dotEnvExists = fs.existsSync('.env')
if (dotEnvExists) {
console.log('env.js: .env exists, probably running on development environment')
process.exit()
}
// On Google Cloud Platform authentication is handled for us
const gcs = require('@google-cloud/storage')()
const bucketName = `envars-stroopy`
console.log(`Downloading .env from bucket "${bucketName}"`)
gcs
.bucket(bucketName)
.file('.env')
.download({ destination: '.env' })
.then(() => {
console.info('env.js: .env downloaded successfully')
})
.catch(e => {
console.error(`env.js: There was an error: ${JSON.stringify(e, undefined, 2)}`)
})