Skip to content

Commit 98f58cb

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

11 files changed

Lines changed: 308 additions & 5025 deletions

File tree

.env

Lines changed: 0 additions & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
EMPTY=
2+
EQUAL_SIGNS=equals==

.secrets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SECRETS_BASIC=secrets_basic

README.md

Lines changed: 5 additions & 10 deletions
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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
const { readEnvs } = require('../src/core')
1+
const core = require('../src/core')
2+
3+
const secrets = core.search()
24

35
module.exports = function babelPluginSecrets({
46
types: { valueToNode, logicalExpression, identifier },
57
}) {
68
return {
79
name: 'babel-plugin-secrets',
810
pre() {
9-
this.values = readEnvs()
11+
this.values = secrets
1012
},
1113
visitor: {
1214
MemberExpression(node) {

package.json

Lines changed: 1 addition & 1 deletion
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.5",
44
"description": "Secret handler for Node.js 🗝️",
55
"main": "src",
66
"scripts": {

0 commit comments

Comments
 (0)