Skip to content

Commit 8f9f918

Browse files
committed
Add try catches to parsing and reference du5rte/create-secret-file
1 parent 9fbaacf commit 8f9f918

11 files changed

+308
-5025
lines changed

.env

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ BASIC=basic
44

55
# previous line intentionally left blank
66
AFTER_LINE=after_line
7-
EMPTY=
87
SINGLE_QUOTES='single_quotes'
98
DOUBLE_QUOTES="double_quotes"
109
SPACED_OUT = "spaced_out"

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33

44
# Mac system files
55
.DS_Store
6+
.yarn-error.log

.invalid.env

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
EMPTY=
2+
EQUAL_SIGNS=equals==

.secrets

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SECRETS_BASIC=secrets_basic

README.md

+5-10
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,10 @@ app.listen(process.env.PORT, function () {
6060
})
6161
```
6262

63-
In ES6
63+
Verify environment variables are loaded in `process.env`
6464

6565
```javascript
66-
// setups entries in process.env
67-
import 'secrets'
68-
// bind process.env to exports
69-
import { PORT } from 'secrets'
70-
71-
...
72-
app.listen(PORT, () => {
73-
console.log(`Server running on localhost:${PORT}`)
74-
});
66+
secret.verify('PORT', 'SECRET') // throw error if it's missing
7567
```
7668

7769
## Babel Plugin
@@ -83,6 +75,9 @@ module.exports = {
8375
}
8476
```
8577

78+
## Github Action
79+
To create secret `.env` environment files on demands on your github actions checkout [du5rte/create-secret-file](https://github.com/du5rte/create-secret-file)
80+
8681
## Location
8782

8883
Secrets should be place in the root of the project but it searches for `.env` files the same way node searches for `node_modules` folders, the closer to the root the higher the priority.

babel-plugin-secrets/plugin.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
const { readEnvs } = require('../src/core')
1+
const core = require('../src/core')
22

33
module.exports = function babelPluginSecrets({
44
types: { valueToNode, logicalExpression, identifier },
55
}) {
66
return {
77
name: 'babel-plugin-secrets',
88
pre() {
9-
this.values = readEnvs()
9+
this.values = core.search()
1010
},
1111
visitor: {
1212
MemberExpression(node) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "secrets",
3-
"version": "1.0.0",
3+
"version": "1.1.4",
44
"description": "Secret handler for Node.js 🗝️",
55
"main": "src",
66
"scripts": {

0 commit comments

Comments
 (0)