-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetEnv.js
More file actions
28 lines (24 loc) · 773 Bytes
/
Copy pathgetEnv.js
File metadata and controls
28 lines (24 loc) · 773 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
26
27
28
// we use :
// platform specific environemt
// local .env environment
// google storage .env environment -- TO BE TESTED
const fs = require("fs");
const dotEnvExists = fs.existsSync(".env");
if (!dotEnvExists) {
console.log("try to download .env");
const { Storage } = require("@google-cloud/storage");
// Creates a client
const gcs = new Storage();
const bucketName = "envvars_spin4athletics";
console.log("downloading .env from ", bucketName);
gcs
.bucket(bucketName)
.file(".env")
.download({ destination: ".env" })
.then(() => {
console.log("getEnv.js -- .env donwloaded successfully");
})
.catch(err => {
console.log("errror downloading ", JSON.stringify(err, undefined, 2));
});
}