-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_secrets.mjs
29 lines (27 loc) · 1.21 KB
/
read_secrets.mjs
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
29
import * as fs from 'fs';
import languageEncoding from 'detect-file-encoding-and-language';
(async () => {
const paths = {
'example_json_file_plaintext': process.env.example_json_file_plaintext,
'example_json_file_secret': process.env.example_json_file_secret,
'example_json_file_sensitive': process.env.example_json_file_sensitive,
'example_text_file_plaintext': process.env.example_text_file_plaintext,
'example_text_file_secret': process.env.example_text_file_secret,
'example_text_file_sensitive': process.env.example_text_file_sensitive,
};
for (const [key, path] of Object.entries(paths)) {
try {
console.log(`Attempting to read ${key}`);
const fileData = fs.readFileSync(path, 'utf8');
console.log(fileData);
const result = await languageEncoding(path);
console.log(result);
} catch (exception) {
if (exception.code === 'ENOENT') {
console.log("Could not find .env.local file! Have you pulled environment variables using 'eas env:pull --environment development'? ");
} else {
console.log(exception);
}
}
}
})();